In my project I have some structure like this:
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; }
};
};
I keep getting an error
`In member function 'foo' error: ‘p’ was not declared in this scope
return p`
I've tried to change p
from protected
to public
, but this did not help. What am I doing wrong?