lundi 30 octobre 2017

Getting the error: expect unqualifeid-id before & token const T LinkedList

template <class T>
const T LinkedList<T>::&getFirst() const
{
    if (!head)
    {
        throw "no element found";
    }
    return head->data;
}

code has a return type of type T where I have so return the first element of the list and throw the exception if the list is empty the definition in the header file looks as follow: virtual const T& getFirst() const; please help.

Aucun commentaire:

Enregistrer un commentaire