Home > Back-end >  About polymorphism in the destructor
About polymorphism in the destructor

Time:09-20

 
Class A {
Int a
};
Class B: public A {
Int b;
Int c;
};

A * aa=new B;
The delete aa;


The code above, inquire of such word memory leak will happen? B in B, c is the destructor is responsible for the resource is returned to the kernel?

CodePudding user response:

No NEW, there would be no memory leak, the release of member variables, it is automatically completed
  • Related