I know this may sound strange, and there ways get around this.but I just wonder if it is possible in c++.
class Item{
public:
string name;
Item(string input){
name = input
cout << this; // unfortunately the std::ostream& operator<<(std::ostream& outstream, Item* item) are not parsed by compiler yet. and this simply prints out its address.
cout << *this; //I don't know how to override `cout << Item`.
}
}
std::ostream& operator<<(std::ostream& outstream, Item* item){
outstream << item->name;
return outstream;
}
std::ostream& operator<<(std::ostream& outstream, Item& item){
outstream << item.name;
return outstream;
}