adspace


What if memory allocation using new fails in C++ how to handle

Answer Posted / Abhay Mishra

"When memory allocation using 'new' fails in C++, it throws a 'bad_alloc' exception. To handle this exception, you can use try-catch blocks as follows:n1. Enclose the code that allocates memory inside a 'try' block.n2. Define a 'catch(bad_alloc)' block to catch the exception.n3. Write your error handling code inside the catch block."n

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Write a java program to find the route that connects between Red and Green Cells. General Rules for traversal 1. You can traverse from one cell to another vertically, horizontally or diagonally. 2. You cannot traverse through Black cells. 3. There should be only one Red and Green cell and at least one of each should be present. Otherwise the array is invalid. 4. You cannot revisit a cell that you have already traversed. 5. The maze need not be in the same as given in the above example

2661


What do you mean by an interface in java?

1098


What is the difference between break and continue statements?

1121


What is the difference between filters and interceptors ?

1308


Hi frnd can i any one kindly can post for me portlet,hibernate and spring example application and with flow explantion configuration using Jdeveloper.and related links ar tutorials kindly please send me .its urgent for me .thanks in advance...........else can any one send to kondaiah.goddeti@gmail.com

2261


What is the difference between equals() and == in java?

1035


What is a constructor overloading in java?

1123


Is minecraft 1.15 out?

1043


How is declarative handling of exceptions done in struts ?

1002


Write a program to print count of empty strings in java 8?

1084


Find Best Job Vacancies across the world on Jooble!

138


What is difference between @controller and @restcontroller in spring?

541


What is latest hibernate version?

486


What is a classloader in java?

1086


What is lazy class?

484