1 2 3 4 5 6 7 8 9 10 11 12
|
class PrimeList {
public:
struct ListNode {
ItemType data;
ListNode *next;
~ListNode (); // destructor
ListNode (const ListNode &N); // copy constructor
ListNode & operator = (const ListNode &N);
} ;
ListNode *first, *last;
} ;
|
For the assignment operator, I figured it out:
PrimeList::ListNode & PrimeList::ListNode::operator = (const PrimeList::ListNode &N) { }
But I cannot figure get the syntax correct for the destructor and copy constructor for ListNode. What is it?
PrimeList::ListNode::~PrimeList::ListNode {
and
PrimeList::ListNode::PrimeList::ListNode (const ListNode &N) {
gives error.
Last edited on
Try
PrimeList::ListNode::~ListNode() {}
Last edited on
Nope. Error reads:
[Error] invalid use of destructor '~PrimeList::ListNode' as a type
I showed you the correct syntax, This error has nothing common with the definition of the destructor I showed.
Last edited on
Ok, it compiled. And from your answer, I figured that for the copy constructor the syntax is:
PrimeList::ListNode::ListNode (const ListNode &N) {}
Thanks.