posted 18 years ago
Regarding D, the compiler automatically provides a default no-arg constructor if none exists. That's the constructor that gets called when DerivedQ48 is new'ed into existence.
Regarding C, remember the object you created is actually an instance of DerivedQ48. Even though you've assigned it to a TestQ48 reference variable (which basically says, "treat me like I'm a TestQ48 object") the underlying object is still an instance of DerivedQ48. Therefore, when you cast it back to its original class, there is no error.
The reverse would not be true.
The first line would give you a conversion error because you're trying to go backwards down the hierarchy.