G
Guest
Hello everyone,
I met with a strange issue that derived class function can not access base
class's protected member. Do you know why?
Here is the error message and code.
thanks in advance,
George
I met with a strange issue that derived class function can not access base
class's protected member. Do you know why?
Here is the error message and code.
Code:
error C2248: 'base::~base' : cannot access protected member declared in
class 'base'
Code:
class base
{
protected:
~base() {}
private:
void foo()
{
base* b = new base;
delete b;
}
};
class derived : public base
{
public:
~derived() {}
private:
void goo()
{
base* b = new derived;
delete b; // error in this line
}
};
thanks in advance,
George