The compiler showed the error:
“
error C2470: ‘SLList’ : looks like a function definition, but there is no parameter list; skipping apparent body
“
I had coded this snippet using a notepad and hence after lots of head banging figured out that the issue was a stupid missed (:):
class SLList
{
private:
Node *header;
public:
SLList()
{
header=NULL;
}
void createList();
void displayList();
int sllLength();
void removeDuplicates();
};
:::::::::::::
:::::::::::::::
int SLList:sllLength()
{
int counter=0;
if(header)
{
Node *temp;
temp=header;
while(temp)
{
counter++;
}
delete temp;
}
return counter;
}
should have been:
int SLList::sllLength()
{
int counter=0;
if(header)
{
Node *temp;
temp=header;
while(temp)
{
counter++;
}
delete temp;
}
return counter;
}