Reputation: 103
function definition
const circularLinkedList<Tp>& operator=(const circularLinkedList<Tp>& otherList);
lines that cause the error, error message refers to line 327, which starts at nodeType....
template <class Tp>
nodeType<Tp>* circularLinkedList<Tp>&::operator=(const circularLinkedList<Tp>& otherList)
And the error messages from the gcc compiler are:
circularLinkedList.h:327: error: invalid declarator before â&â token
circularLinkedList.h:327: error: expected initializer before â&â token
I assume that I have made some sort of syntax error in in defining this method somewhere. How would I have to go about fixing it? Thanks.
Upvotes: 0
Views: 269
Reputation: 4217
In the first code block, you show the method declaration, not the function definition. In the second code block, you show the header of the method definition.
Method Declaration:
Returns const circularLinkedList<Tp>&
Method Definition:
Returns nodeType<Tp>*
.
You are not defining the method you declared. You are defining some method you have not declared.
The header of the definition should be:
const circularLinkedList<Tp>& circularLinkedList<Tp>::operator=(const circularLinkedList<Tp>& otherList)
Upvotes: 0
Reputation: 4039
Can you post a little bit more code for us? Can you explain what nodeType is?
The following looks like a function definition:
template <class Tp>
nodeType<Tp>* circularLinkedList<Tp>&::operator=(const circularLinkedList<Tp>& otherList)
However, for one thing, the declaration says it returns a const circularLinkedList<Tp>&
.
Also, you don't want to have the &
before the ::
. It needs to be the type's name, not a pointer or reference to a variable of that type. If you want that behavior you need to use a proxy class.
So it should be something like:
template <class Tp>
const circularLinkedList<Tp>& circularLinkedList<Tp>::operator=(const circularLinkedList<Tp>& other)
Which should almost invariably end with return *this;
Upvotes: 2