マップ内のマップされた値で使用するためにoperator<< をオーバーロードするのに問題があります:
map<string,abs*> _map;
// that my declaration, and I have filled it with keys/values
これらの両方を試しました:
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;
}
私のプログラムでは、単に次のように呼び出します。
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
私も試しました:
std::cout << *_map["key"] << std::endl;
// trying to call overloaded operator for mapped value
// And that gives me a really long compile time error
アドレスの代わりに、マップされた値の値を出力するためにこれを取得するために何を変更できるか知っている人はいますか?
どんな助けでも大歓迎です