Re: derived class can not access base class protected member?
- From: "Peter Oliphant" <peteroid69@xxxxxxxxxxx>
- Date: Thu, 25 Oct 2007 16:51:04 -0700
private:
void foo()
Because foo( ) is defined as PRIVATE (not protected) in the base class (typo?)... ;)
[==Peter==]
"George" <George@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message news:D783AA73-AC91-45C2-B534-112BEFEC3BAA@xxxxxxxxxxxxxxxx
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.
[Code]
error C2248: 'base::~base' : cannot access protected member declared in
class 'base'
[/Code]
[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
}
};
[/Code]
thanks in advance,
George
.
- Follow-Ups:
- Prev by Date: Re: nullptr for VS2005 but what about VS2003?
- Next by Date: Generate tlh/tli from a tlb?
- Previous by thread: Re: derived class can not access base class protected member?
- Next by thread: Re: derived class can not access base class protected member?
- Index(es):
Relevant Pages
|