g++ – c++ error: expected type-specifier

g++ – c++ error: expected type-specifier

b’

intSLList* mylist = new intSLList::intSLList();n

n

This is wrong. When we write new intSLList(), were not calling the constructor xe2x80x94 merely naming the type xe2x80x94 and therefore naming the constructor in full (as intSLList::intSLList) is flat-out wrong.

n

So:

n

intSLList* mylist = new intSLList();n

n

You dont need dynamic allocation here anyway:

n

#include intSLList.hhnnint main()n{n   intSLList mylist;nn   for (int i = 0; i < 10; i++) {n      mylist.AddToTail(i);    n   }nn   mylist.Print();n}n

Youre trying to call the constructor as a function. The constructor will be called automatically when you allocate the object, so change to

n

intSLList mylist;n

n

Thats it, no need for pointers or dynamic allocation at all.

g++ – c++ error: expected type-specifier

Leave a Reply

Your email address will not be published.