Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

expected a qualified name after 'typename'

Tags:

c++

template<typename Type> class SingleList;

template<typename Type> class ListNode{
private:
    friend typename SingleList<Type>;  
    //this line appears"expected a qualified name after 'typename'"

    ListNode():nextNode(NULL){}

    ListNode(const Type item,ListNode<Type> *next=NULL):nodeData(item),nextNode(next){}

    ~ListNode(){
        nextNode=NULL;
}

public:
        Type GetData();
        friend ostream& operator<< <Type>(ostream& ,ListNode<Type>&);

private:
        Type nodeData;
        ListNode *nextNode;
};

The code:

friend typename SingleList<Type>;  

expected a qualified name after 'typename' and how to solve it. Thank you.

like image 892
tonysok Avatar asked Aug 01 '13 15:08

tonysok


1 Answers

You want

friend class SingleList<Type>;

typename can be used instead of class inside the template parameter declaration, but not everywhere.

like image 60
Ben Voigt Avatar answered Oct 03 '22 19:10

Ben Voigt