C++ Compilation Error: error C2470: ‘SLList’ : looks like a function definition, but there is no parameter list; skipping apparent body


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;
}

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s