I'm having a really werid issue with overloading the insertion operator (<<).
Here's my code snippet:

    class instream
        void operator<< (instream&, char[]);

Visual Studio keeps telling me I have "too many arguments for binary operator <<". I don't see the problem here. Is there something obvious I'm missing?

Recommended Answers

All 2 Replies

Alright. So, operators of this type HAVE to be friend functons. Makes sense. I think...

Since this is a member of the class (not a static method), you can leave off the first argument and in the body of the method do this:

void instream::operator<<(char[] data)

Just an aside, if this is an input stream, why are you writing an output operator?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.