Im having an issue using my operator<< overload, I am creating a pointer to a ClassA and storing it in a list, then I get the pointer out of my list using an iterator and when I try to cout << (*iterator) I get the address itself, I dont get the actual operator<< overload to execute ...
This is a reduced version of the code to illustrate what I am doing (the full code is kind of very long)...
Ive got a Class A declared as follows:
Header File (A.h)
Implementation (A.cpp)
Now, this is the calling code from a different class & file:
Implementation (Manager.cpp)
Any clues why this is not working?
Any help would be much appreciated.
Thanks,
This is a reduced version of the code to illustrate what I am doing (the full code is kind of very long)...
Ive got a Class A declared as follows:
Header File (A.h)
Code:
class A
{
friend ostream& operator<< ( ostream &, const A & );
private:
string sRecord;
};
Implementation (A.cpp)
Code:
ostream &operator<<( ostream &sout, const A &a )
{
sout << "Record: " << a.sRecord << endl;
}
Now, this is the calling code from a different class & file:
Implementation (Manager.cpp)
Code:
string stringRecord = "Something";
List.push_back(new A(stringRecord));
list<A*>::const_iterator itrA;
itrA = List.begin();
// this is the code that isnt working as expected
// I would exepct this to launch the overloaded operator<< of A but instead it returns (00257200)
cout << (*itrA);
Any clues why this is not working?
Any help would be much appreciated.
Thanks,