P
persenaama
But it isn't good programming practice in C++.
You're confused. That is a very common pattern in C++ programs and well
accepted, nothing bad or magical is happening.
The whole point is that the program doesn't already "know" about the
types Derived1 and Derived2 in the scope where it only sees Base*, it
only knows the common interface to the base class. If the destructor
isn't virtual, how the correct destructor is called, you propose to
work around this.. how?
Your program already knows about types Derived1 and Derived2
so you might as well use them in the calling program.
You're confused. That is a very common pattern in C++ programs and well
accepted, nothing bad or magical is happening.
The whole point is that the program doesn't already "know" about the
types Derived1 and Derived2 in the scope where it only sees Base*, it
only knows the common interface to the base class. If the destructor
isn't virtual, how the correct destructor is called, you propose to
work around this.. how?