C++ Template: 'is not derived from type'

后端 未结 2 847
忘掉有多难
忘掉有多难 2021-01-18 06:04

Why is this code not valid?

#include 

template 
class A {
  public:
    A() { v.clear(); }

    std::vector *&         


        
2条回答
  •  礼貌的吻别
    2021-01-18 06:52

    You need to add typename as the types depend on each other and the compiler can't figure out if it really is a type.

    However, on gcc 4.5.0 i get a more concise error message:

    test.cc:8:3: error: need ‘typename’ before ‘std::vector*>::const_iterator’ because ‘std::vector*>’ is a dependent scope

提交回复
热议问题