在我的项目中,我有一些像这样的结构:
template <typename T>
class deque
{
// ...
class MyIterator
{
protected:
T* p;
public:
MyIterator(T* x)
: p(x)
{
}
};
class Iterator: public MyIterator
{
public:
Iterator(T* x)
: MyIterator(x)
{
}
T* foo() { return p; }
};
};
我一直收到错误
`In member function 'foo' error: ‘p’ was not declared in this scope
return p`
我尝试将p
从protected
更改为public
,但这没有用。我做错了什么?