I have the following class(prototipe):
class Token
{
public:
//members, etc.
friend std::stringstream& operator<< (std::stringstream &out, Token &t);
};
And the operator is implemented like this:
std::stringstream & operator<< (std::stringstream &out, Token &t)
{
out << t.getValue(); //class public method
return out;
}
Now, I'm trying to use it like this:
std::stringstream out;
Token t;
//initialization, etc.
out << t;
And VS gives me error, saying that there is no match for << operator. What am I wrong in?
std::stringstream & operator<< (std::stringstream &out, Token &t)
should be
std::ostream & operator<< (std::ostream &out, Token const &t)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With