-
What is the output of this program?
#include <iostream>
#include <new>
using namespace std;
struct N
{
virtual ~N() { };
void operator delete(void* ptr1)
{
cout << "N :: operator delete" << endl;
}
};
struct M : N
{
void operator delete(void* ptr1)
{
cout << "M :: operator delete" << endl;
}
};
int main()
{
N* ptr2 = new M;
delete ptr2;
}
-
- Compilation Error
- N :: operator delete
- M :: operator delete
- Runtime Error
- None of these
Correct Option: C
In this program, We are passing the value to the M, So we are printing M::operator delete.