Mam następujące klasy (prototipe):C++ std :: stringstream operator << przeciążenia
class Token
{
public:
//members, etc.
friend std::stringstream& operator<< (std::stringstream &out, Token &t);
};
a operator jest realizowany tak:
std::stringstream & operator<< (std::stringstream &out, Token &t)
{
out << t.getValue(); //class public method
return out;
}
Teraz usiłuję używać go tak:
std::stringstream out;
Token t;
//initialization, etc.
out << t;
i VS daje mi błąd, mówiąc, że nie ma odpowiednika dla < < operator. W czym się mylę?
Witamy w SO. Kiedy podajesz próbki kodu, zachowaj je w jednym, nadającym się do kompilacji kodzie. I * zawsze * daje pełne błędy kompilatora. – thiton