Im having trouble overloading operator<< for use with the mapped value in my map:
map<string,abs*> _map;
// that my declaration, and I have filled it with keys/values
Ive tried both of these:
std::ostream& operator<<(std::ostream& os, abs*& ab)
{
std::cout << 12345 << std::endl;
}
std::ostream& operator<<(std::ostream& os, abs* ab)
{
std::cout << 12345 << std::endl;
}
In my program I simply call:
std::cout << _map["key"] << std::endl;
// trying to call overloaded operator for mapped value
// instead it always prints the address of the mapped value to screen
Ive also tried:
std::cout << *_map["key"] << std::endl;
// trying to call overloaded operator for mapped value
// And that gives me a really long compile time error
Anyone know what I could change to get this to output the value of the mapped value, instead of the address?
Any help is appreciated
Don’t use
absas a type –absis a function declared incstdlibheader. You didn’t provide declaration of that type so this example is using some fictiveAbstype:Output: