Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6712637
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T08:16:58+00:00 2026-05-26T08:16:58+00:00

This is my assignment question Create a class with its own operator new. This

  • 0

This is my assignment question

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

Now I don’t want the program, but I am confused with this question. I can handle new operator overloading, but as asked I should create a static member “release()”. And if I have to recover in catch, how do I recover? I mean what object should I delete.
Or my prototype for release() is wrong?

Edit:
Also if I have to delete, which of the 5 objects can I delete? And deleting any object would in fact be incorrect. I see no way of recovery.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T08:16:59+00:00Added an answer on May 26, 2026 at 8:16 am

    Sounds like you would need something like a static list of addresses in your class. Whenever new is called you store the address of the memory block in that list. Then in your release method you go through the static list and free the memory plus throw the exception.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For this assignment I had to create my own string class. I initially wrote
I've this question from an assignment to create a Store which rent out books,
Inspired by this question . Usually the reason to make copy-constructor and assignment operator
This is a question corresponds to my uni assignment so I am very sorry
Disclaimer: This is for a homework assignment, but the question is not regarding the
This is not exactly a straight-out question because I have just solved it, but
This is a practice assignment where I have to create a table space with
Please help with my assignment. Here is the question: Create a separate test driver
I have a Assignment question about Java Generics. The given class is Product.java. It
I'm somewhat new to C++ so, I guess this is a very basic question.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.