Joshua
Joshua

Reputation: 4320

Error: expected unqualified-id before & token

I'm very new to C++ and I am creating my first class. I have every error out of the way except one:

error: expected unqualified-id before & token

The assignment operator signature looks like this:

Job::& operator = (const Job &v )

I've tried everything I can think of, removing the &, doing Job::Job & operator, removing the Job. Nothing works.

I know it's simple, I just don't know what it is.

Upvotes: 3

Views: 12883

Answers (1)

Tugrul Ates
Tugrul Ates

Reputation: 9687

When declaring inside the class definition:

Job& operator = (const Job &v )

When defining outside the class definition:

Job& Job::operator = (const Job &v )

Upvotes: 9

Related Questions