class – Error C++ requires a type specifier for all declarations whilst defining methods

class – Error C++ requires a type specifier for all declarations whilst defining methods

you declared it as void but you forgot to put it in the definition. should be:

void StringList::PrintWords()

Your member function PrintWords is prototyped as:

void PrintOn();

Meaning it returns void. When you implement your function elsewhere you still have to provide the return type, which youve mistakenly left out:

/* void */ StringList::PrintOn() { ... }

class – Error C++ requires a type specifier for all declarations whilst defining methods

Put a void in front of the line giving you issues.

Even though it feels redundant, you have to specify the return type both in the declaration and the implementation.

Leave a Reply

Your email address will not be published.