我有下面的類(prototipe):C++的std :: stringstream的運營商<<重載
class Token
{
public:
//members, etc.
friend std::stringstream& operator<< (std::stringstream &out, Token &t);
};
且操作者實施這樣的:
std::stringstream & operator<< (std::stringstream &out, Token &t)
{
out << t.getValue(); //class public method
return out;
}
現在,我想使用這樣的:
std::stringstream out;
Token t;
//initialization, etc.
out << t;
而且VS給了我的錯誤,說是有敵不過< <運營商。我在錯什麼?
歡迎SO。當您提供代碼示例時,請保留一份可編譯的代碼。並*總是*給出完整的編譯器錯誤。 – thiton 2012-01-12 11:11:49