#include <vector>
#include <iostream>
template <class T>
class Base
{
protected:
std::vector<T> data_;
};
template <class T>
class Derived : public Base<T>
{
public:
void clear()
{
data_.clear();
}
};
int main(int argc, char *argv[])
{
Derived<int> derived;
derived.clear();
return 0;
}
我无法编译这个程序。我得到:
main.cpp:22: error: 'data_' was not declared in this scope
拜托,你能解释一下为什么在课堂上看data_
不到吗?Derived