Conversion of pointer-to-pointer between derived and base classes?
If this was allowed, you could write this:
*bb = new Base;
And c
would end up pointing to an instance of Base
. Bad.
Pointers are virtual address. Normally you are responsible for what you do with it. Using msvc 2019. I can cast one to base, but not two:
example 1:
int p;
int *p1 = &p;
int **p2 = &p1; //OK
example 2:
struct xx {};
struct yy : public xx {};
yy p;
yy *p1 = &p;
xx **p2 = &p1; //Just a strange error
example 3:
struct xx {};
struct yy : public xx {};
yy p;
xx *p1 = &p;
xx **p2 = &p1; //OK