Is it possible to have inheritance with no virtual methods? The compiler is saying that the following code is not polymorphic.
Example:
Class A(){
A a;
B *b = dynamic_cast(a)
Here a is an object and b is a pointer.
Actually, upcasting and downcasting are both allowed in C++. But when using downcasting, 2 things should be pay attention to: 1 The superclass should has at least one virtual method. 2 Since superclass is "smaller" than subclass, one should use memory object carefully.