T
Taras_96
Hi everyone,
Herb Schildt in "C++, the complete reference" writes:
"In C++, it is illegal to convert one type of pointer into another
without the use of an
explicit type cast. For this reason, the preceding program will not
even compile if
you try to compile it as a C++ (rather than as a C) program. However,
the type of
error described can still occur in C++ in a more roundabout manner."
However, the following works with g++ without any errors:
Derived* pDerived = new Derived();
Base* pBase = pDerived;
What was Herb referring to when he said it is illegal to cast from one
type to another (possibly he meant from one class to an unrelated
class, or from an int to a float)
Taras
Herb Schildt in "C++, the complete reference" writes:
"In C++, it is illegal to convert one type of pointer into another
without the use of an
explicit type cast. For this reason, the preceding program will not
even compile if
you try to compile it as a C++ (rather than as a C) program. However,
the type of
error described can still occur in C++ in a more roundabout manner."
However, the following works with g++ without any errors:
Derived* pDerived = new Derived();
Base* pBase = pDerived;
What was Herb referring to when he said it is illegal to cast from one
type to another (possibly he meant from one class to an unrelated
class, or from an int to a float)
Taras