M
ManicQin
Hi lets say I have the next situation
class base
{
pubic:
base() {}
virtual ~base(){}
virtual init()
{//do init }
};
now i want that every deriver will call MY init function before he
init his class...
for some reasons I cannot put those calls in the cTor...
one thing that I thought of is
class base
{
public:
init()
{
//do base's init
secondPhaseInit();
}
protected:
virtual secondPahseInit() = 0;
}
and then the deriver can only override secondPhaseInit and he needs to
go through my init .
But it's still not an idiot proof method... is there a way?
class base
{
pubic:
base() {}
virtual ~base(){}
virtual init()
{//do init }
};
now i want that every deriver will call MY init function before he
init his class...
for some reasons I cannot put those calls in the cTor...
one thing that I thought of is
class base
{
public:
init()
{
//do base's init
secondPhaseInit();
}
protected:
virtual secondPahseInit() = 0;
}
and then the deriver can only override secondPhaseInit and he needs to
go through my init .
But it's still not an idiot proof method... is there a way?