Re: Clarify me on this example
No, not necessarily. It all depends on how the classes are declared and what their lifetimes are.
In your example just remove the 'delete' line. The car object will be automatically destructed when the execution leaves 'main()'
Code:
int main()
{
CVehicle *m_VehicleType;
CCar m_Car;
m_VehicleType = &m_Car;
} << m_Car destroyed here.
"It doesn't matter how beautiful your theory is, it doesn't matter how smart you are. If it doesn't agree with experiment, it's wrong."
Richard P. Feynman