You are viewing a single comment's thread. Return to all comments →
Note: This is a very bad code example!
The code is producing memory leaks!!! none of the cast spells is ever deallocated in main. Do not do that! if you need a polymorphic return use std::shared_ptr and make_shared or unique_ptr and make_unique.