Sail E0 Webinar
Question


What is the output of this program?


1.
#include
2.
#include
3.
using namespace std;
4.
class X
5.
{
6.
public:
7.
void* operator new(size_t sz) throw (const char*)
8.
{
9.
void* p = malloc(sz);
10.
if (p == 0)
11.
throw "malloc() failed";
12.
return p;
13.
}
14.
void operator delete(void* p)
15.
{
16.
cout
Options:
A .  X::operator delete(void*)
B .  Freeing 400 bytes
C .  Depends on the compiler
D .  Both a & c
Answer: Option D

The memory value allocated for the program depends on compiler ony.
$ g++ free2.cpp
$ a.out
X :: operator delete(void*)
Freeing 400 bytes



Was this answer helpful ?
Next Question

Submit Solution

Your email address will not be published. Required fields are marked *

Latest Videos

Latest Test Papers