C++ equivellant to if <> Self

BlitzMax Forums/BlitzMax Programming/C++ equivellant to if <> Self

verfum(Posted 2008) [#1]
Hi I hope I'm not being cheeky here but I'm hoping there is a c++ programmer here that could help me, I'm after the Blitzmax equivillant to:
if object:Object <> Self Then


So that the object isn't comparing itself in the code, the object:Object is from a for look looking through a list. This is what I have come up with so far but they dont work:
if(*iter ? !this : false){
if((*iter) != this){


The iterator is similar to the object:Object, it's something to flick through a list.

Thanks.


Who was John Galt?(Posted 2008) [#2]
if obj:object<>object(self)

I think you will have to do the cast to compare, but maybe not


sswift(Posted 2008) [#3]
	Function DrawAll()		
			
			Local ThisSprite:Sprite				
				
			' Draw sprites.
				For ThisSprite = EachIn SpriteList
					ThisSprite.Draw()
				Next
			
		End Function



I don't code in C++, but if I understand you right, you're doing a loop like that, but in a method instead of a function?

If that's the case, then I think all you need is to say If ThisSprite <> Self.


[edit]
I think I misunderstood you though. You're trying to do this with generic objects, like those the List type works with. So it's not as simple as that. In that case I can't help ya, I don't do that sort of thing much.
[/edit]


Brucey(Posted 2008) [#4]
Except he asked for an example in C++ :-)


verfum(Posted 2008) [#5]
Yeah here is that in c++
void drawAll()
	{
		list<Sprite*>::iterator iter;

		for(iter = this->m_list.begin(); iter != this->m_list.end(); iter++)
		{

		      (*iter)->draw();	
			
		}
	}



verfum(Posted 2008) [#6]
Yeah the problem is an equivillent to
For obj:TObject = Eachin obj_list
      If obj <> Self Then

in c