0

So I'm trying to overload the << operator. From all the sources I can see, the syntax is correct, but eclipse doesn't like it.

I'm getting a couple errors: Polynomial::PrivateStruct* Polynomial::head is private

And: struct Polynomial::PrivateStruct is private.

I want to keep this struct private as to hide implementation details.

std::ostream& operator<<(std::ostream& outputStream, Polynomial& rhs)
    {
        Polynomial::PrivateStruct *p = rhs.head;
        //implementation details
        return outputStream;

    }

and the declaration:

friend std::ostream& operator<<(std::ostream& outputStream, const Polynomial& rhs);
Scuba Steve
  • 1,541
  • 1
  • 19
  • 47

1 Answers1

6

The declaration and the definition don't match - one takes a reference to const, the other to non-const. Match them and you're good to go.

jrok
  • 54,456
  • 9
  • 109
  • 141