HI Not really an OSG question this really belongs on a C++ user list, Note the function declaration bool MyClass::MyMethod(std::vector<MyClass> MyVector) here you should be passing in your vector as a reference or pointer, you should ALWAYS pass any none POD variables as a references or even the evil pointer ( we shall ignore constness at this point : ) ) you are actually making a full copy of your vector and all it contents as shown
As defined you need something like ((MyClass&)(MyIterator)).AnotherMethod() ; note the DOT operator is used here not the -> operator. this is because you vector as shown does not contain pointers you might want to change your vectors declaration to use class pointers rather class instances and pass by reference If you were using pointers then you would be able to use the deference operator __________________________________________________________ Gordon Tomlinson Email : [EMAIL PROTECTED] Website : www.vis-sim.com www.gordontomlinson.com __________________________________________________________ "Self defence is not a function of learning tricks but is a function of how quickly and intensely one can arouse one's instinct for survival" -Master Tambo Tetsura _____ From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Renan Mendes Sent: 29 December 2007 16:48 To: OSG Mailing List Subject: [Norton AntiSpam] [osg-users] STL vectors and function calls Hi, everyone. I've got quick question on STL vectors. I've created a class (let's call it MyClass) with the method 'bool MyMethod(std::vector<MyClass> MyVector)' that calls another method 'void AnotherMethod()' that makes a simple check on a variable inherent to every instance of MyClass. How do I write that method? Or better put: how do I change the following code to make it right? bool MyClass::MyMethod(std::vector<MyClass> MyVector) { std::vector<MyClass>::iterator MyIterator; for(MyIterator = MyVector.begin(); MyIterator != MyVector.end(); MyIterator++) { *MyIterator->AnotherMethod(); } } I read that an iterator was a pointer to the content of the vector, why doesn't it work? Thanks, Renan M Z Mendes
_______________________________________________ osg-users mailing list [email protected] http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

