Templates and nested classes/structures

后端 未结 2 1611
轮回少年
轮回少年 2021-01-11 22:04

I have a simple container :

template  list {
    public:
        struct node {
            nodeType info;
            node* next;
              


        
2条回答
  •  死守一世寂寞
    2021-01-11 23:04

    that's because node is a dependent type. You need to write the signature as follows (note that I have broken it into 2 lines for clarity)

    template  
    typename list::node* list::_search() 
    {
        //function
    }
    

    Note the use of the typename keyword.

提交回复
热议问题