P
Pierre Couderc
In the following example, I want that ABC::f() be called. Is it possible?
Here I have simplified the problem, but the point is that I have to
store the pointer on the ABC object in a pointer on a A object (line [1]).
and when I use it (line [2]), I know that pp points on a AC object but
not on a ABC object.
I have tried many casts (static_cast, dynamic_cast, even
reinterpret_cast) but I do not success.
Is there a pure C++ solution, and else is there a MS VC6++ solution?
Thanks in advance
Pierre Couderc
class A
{
public:
A(){ ;}
virtual ~A(){;}
int dummy;
};
class AB : public virtual A
{
public:
AB() {;}
};
class AC : public virtual A
{
public:
AC() {;}
virtual void f(){;}
};
class ABC : public AB, public AC
{
public:
~ABC(){;}
void f(){println();}
};
int main(int argc, char* argv[])
{
ABC* p= new ABC;
A* pp=p; //[1]
AC* ppp= ????_cast<AC*> (pp); // [2]
ppp->f();
return 0;
}
Here I have simplified the problem, but the point is that I have to
store the pointer on the ABC object in a pointer on a A object (line [1]).
and when I use it (line [2]), I know that pp points on a AC object but
not on a ABC object.
I have tried many casts (static_cast, dynamic_cast, even
reinterpret_cast) but I do not success.
Is there a pure C++ solution, and else is there a MS VC6++ solution?
Thanks in advance
Pierre Couderc
class A
{
public:
A(){ ;}
virtual ~A(){;}
int dummy;
};
class AB : public virtual A
{
public:
AB() {;}
};
class AC : public virtual A
{
public:
AC() {;}
virtual void f(){;}
};
class ABC : public AB, public AC
{
public:
~ABC(){;}
void f(){println();}
};
int main(int argc, char* argv[])
{
ABC* p= new ABC;
A* pp=p; //[1]
AC* ppp= ????_cast<AC*> (pp); // [2]
ppp->f();
return 0;
}