尝试使用模板继承时出现奇怪的错误。 这是我的代码:模板继承和基本成员变量
template <class T> class A {
public:
int a {2};
A(){};
};
template <class T> class B : public A<T> {
public:
B(): A<T>() {};
void test(){ std::cout << "testing... " << a << std::endl; };
};
这是错误:
error: use of undeclared identifier 'a'; did you mean 'std::uniform_int_distribution<long>::a'?
void test(){ std::cout << "testing... " << a << std::endl; }
而在情况下,它可能会影响到一些我使用这些标志:
-Wall -g -std=c++11
我真的不知道什么是错的,因为与没有模板的纯类相同的代码工作正常。
'无效测试(){性病::法院<< “测试...” << A ::一<< std :: endl; };' –
Rerito