Question: this is my code #include #include #include using namespace std; class c{ public: void *operator new(size_t size){ c();{ int i = 0; while (true){ cout

 this is my code #include #include #include using namespace std; class

this is my code

#include #include #include using namespace std;

class c{ public:

void *operator new(size_t size){ c();{ int i = 0;

while (true){ cout

if (i >= 10) {throw i+1;}}} }};

int main(){

c *Object = new c; while (true){ try {c Object;}

catch (int x) {cout

return 0; }

it didn't work, so if anyone can show me a correct version that fulfils ALL requirements, it would be very appreciated!!!!!

it uses c++, thank you!

3.1 Create a class with its own operator new. This operator should allocate ten objects, and on the eleventh object run out of memory and throw an exception. Also add a static member function that reclaims this memory. Now create a main() with a try block and a catch clause that calls the memory-restoration routine. Put these inside a while loop, to demonstrate recovering from an exception and continuing execution

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!