hi,i got a class toy,and i got 3 pointer objects of that class. all the 3 pointer objects are in a vector and I want a iterator to loop it.
i get error in the last part.looping to print out all the name.hope some one can help out.thanx alot.Code:class toy{ private: string name; public: toy(string newName){ name=newName; } void getName(){ cout<<name<<endl; } }; int main(void){ toy *a=new toy("a"); toy *b=new toy("b"); toy *c=new toy("c"); vector<toy*>list; list.push_back(a); list.push_back(b); list.push_back(c); //loop to print out all the name. vector<toy*>::iterator ptr;int i=0; while(ptr != list.end() ){ ptr->getName(); ptr++; } }