constオブジェクトの演算子<<のオーバーロードに問題があります。問題を見つけることができませんでした
#include <iostream>
using namespace std;
class T
{
friend ostream& operator<<(ostream& os,T& t)
{
os << "Val : " << t.value << endl;
return os;
}
private:
int value;
public:
T(int v) { value=v; }
int getValue() const { return value; }
};
int main()
{
const T t(2);
cout << t;
return 0;
}
コンパイラメッセージ:
エラーC2679:バイナリ'<<':タイプ'const T'の右側のオペランドをとる演算子が見つかりません(または受け入れ可能な変換がありません)