<< requires exactly one argument

I keep getting this error with my code.

1
2
3
4
ostream& Set::operator<<(ostream& out, const Set& v){
    out << v.toStr();
    return out;
}


Here is a header file
 
friend ostream& operator<< (ostream&, const Set&);
Take out the Set:: bit. The function is global, not a member of Set.
To explain further:

You can define the streaming operator either to be a member of the class, in which case, it only takes 1 argument, or as a free function, in which case it takes 2 arguments.

What you've tried to do is define it as a class member, but to still take 2 arguments.

Topic archived. No new replies allowed.