[co
de]
"Please use code tags"
[/co
de]
_ ¿why virtual destructor?
So it calls the proper destructor.
Test this:
1 2
|
Base *obj = new Derived;
delete obj;
|
_ does the overrided method also has to be have the keyword 'virtual'?
No, you don't need to write it. ¿why would you want to do that?
_ If you declare a class inside a function, then it will only be visible inside that function.
You can't create B or C objects outside that function, because the compiler will not know what they are.
_ As to why you don't observe the polymorphic behaviour
ist<A> listOfAs;
has objects of type A. They were sliced from a B and a C, but they are A.
You would observe if you have a pointer or a reference of the base type pointing to the derived type.
_ main must return
int