为什么此代码无效?C++模板:'不是从类型派生的'
#include <vector>
template <typename T>
class A {
public:
A() { v.clear(); }
std::vector<A<T> *>::const_iterator begin() {
return v.begin();
}
private:
std::vector<A<T> *> v;
};
GCC报告下列错误:
test.cpp:8: error: type 'std::vector<A<T>*, std::allocator<A<T>*> >' is not derived from type 'A<T>'
test.cpp:8: error: expected ';' before 'begin'
test.cpp:12: error: expected `;' before 'private'
有什么不对?如何解决它?