LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 10-03-2008, 02:29 AM   #1
The_Nerd
Member
 
Registered: Aug 2002
Distribution: Debian
Posts: 540

Rep: Reputation: 32
Strange compiling results with std::vector


I have a problem that suddenly popped up, and I am not quite sure what it is...
Forenote: I can not paste all of my code because my projects is rather large.

When I try to use a vector<T>::iterator, I get the following compile errors. As I said, this just suddenly started happening (and may have something to do with "Freetype", as it seams to have started after I included freetype in my project.

Code:
$make
g++ -DLINUX -DUSE_RENDERER_GL -g -O2 -Iinclude/ -IBox2D/Include -I/usr/include/freetype2 -Wreturn-type -c source/particle.cpp -o source/particle.o
source/particle.cpp: In member function ‘void Ner2D::Particle::CEmitter::Update()’:
source/particle.cpp:45: error: conversion from ‘std::_List_iterator<Ner2D::Particle::CParticle>’ to non-scalar type ‘__gnu_cxx::__normal_iterator<const Ner2D::Particle::CParticle*, std::vector<Ner2D::Particle::CParticle, std::allocator<Ner2D::Particle::CParticle> > >’ requested
source/particle.cpp:45: error: no match for ‘operator!=’ in ‘Itr != ((Ner2D::Particle::CEmitter*)this)->Ner2D::Particle::CEmitter::Particles. std::list<_Tp, _Alloc>::end [with _Tp = Ner2D::Particle::CParticle, _Alloc = std::allocator<Ner2D::Particle::CParticle>]()’
source/particle.cpp:47: error: passing ‘const Ner2D::Math::Types::CPoint’ as ‘this’ argument of ‘Ner2D::Math::Types::CPoint& Ner2D::Math::Types::CPoint::operator+=(const Ner2D::Math::Types::CVector&)’ discards qualifiers
make: *** [source/particle.o] Error 1
Here is the function:
Code:
/*--------------------------------------------------------------------*/
void CEmitter::Update()
{
	for (vector<CParticle>::iterator Itr = Particles.begin() ; Itr != Particles.end() ; Itr++)
	{
		(*Itr).Position += (*Itr).Velocity;
	}
}
And here is the header file:
Code:
#ifndef _PARTICLE_H_
#define _PARTICLE_H_
#include <vector>
#include "video.h"
#include "n2d_math.h"

using namespace std;

namespace Ner2D
{
	namespace Particle
	{
		class CParticle
		{
			public:
				Math::Types::CPoint Position;
				Math::Types::CPoint Size;
				Math::Types::CVector Velocity;
				long lGroup;
				Ner2D::Types::CAutoPointer<Ner2D::Material::CMaterial> Material;
				
				CParticle &operator=(const CParticle &Par);
				CParticle();
				CParticle(const CParticle &Par);
		};
		
		class CEmitter : public Renderer::CPrimitive, public NER2D_BASE_TYPE
		{
			public:
				NER2D_CLASS_HEADER(CEmitter);
				
				virtual void Draw();
				virtual bool IsBlended() { return true; }
				virtual ~CEmitter() {}
				void Update();
				CParticle *AddParticle(Ner2D::Types::CAutoPointer<Ner2D::Material::CMaterial> _Material = NULL);
				
				string Name;
			protected:
				list<CParticle> Particles;
		};
	}
}

#endif
I will greatly apprciate any help.
 
Old 10-03-2008, 02:34 AM   #2
The_Nerd
Member
 
Registered: Aug 2002
Distribution: Debian
Posts: 540

Original Poster
Rep: Reputation: 32
Never mind... a moderator can delete this post... I was stupid enough to try to use a vector<T>::iterator on an std::list... I forgot I decided to change it to a list (:P)
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Who is using Vector Linux 5.8 Std Gold? bobby_hawk VectorLinux 22 09-08-2008 10:18 AM
Vector 5.8 std Mouse setup help sickley VectorLinux 2 01-09-2007 02:20 PM
how to sort std::vector<double>? markhod Programming 4 10-12-2005 04:21 AM
how to access elements of std::vector<int>* markhod Programming 3 08-02-2005 10:17 AM
std::vector <> ::max_size ta0kira Programming 1 04-29-2005 04:59 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:02 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration