Need typename error (template related error)

后端 未结 2 476
野的像风
野的像风 2021-01-29 00:17

I have a class called node inside another class which is templated. Some of the methods of class Node returns Node pointer. This is an excerpt of how I implemented



        
2条回答
  •  梦毁少年i
    2021-01-29 00:44

    To clarify, the compiler has no idea that myClass::Node is now or ever will be a type. Think of it this way:

    template 
    class A
    {
    public:
        typedef T value_type;
    };
    
    template 
    class B
    {
    public:
       typename A::value_type x;
    };
    
    template <> A { public: static int value_type=10;}
    

    You have to make the promise to the compiler that the type is a typename. It defaults to assuming that it is a value.

提交回复
热议问题