In the following code, will small c
will leak ?
I believe that not, as it is not dynamically allocated, the struct will be deleted entirely
From my peers I got the following answers :
- It is undefined behavior
- It will leak
- It wont leak
Here is the code :
class A
{
public:
void printA() { cout << "A" << endl;}
virtual void printB() { cout << "B" << endl;}
int a;
};
class C : public A
{
public :
void printA() { cout << "C" << endl;}
void printB() { cout << "D" << endl;}
int c;
};
int main()
{
A* bla = new C();
bla->printA();
bla->printB();
delete bla;
return 0;
}