C++ Institute CPA - C++ Certified Associate Programmer CPA-21-02 Question # 48 Topic 5 Discussion

C++ Institute CPA - C++ Certified Associate Programmer CPA-21-02 Question # 48 Topic 5 Discussion

CPA-21-02 Exam Topic 5 Question 48 Discussion:
Question #: 48
Topic #: 5

Given:

#include

#include

using namespace std;

int main () {

try

{

int * myarray= new int[1000];

}

catch (bad_alloc&)

{

cout << "Error allocating memory";

}

catch (exception& e)

{

cout << "Standard exception";

}

catch (...)

{

cout << "Unknown exception";

}

return 0;

}

What will happen if we use the operator “new” and the memory cannot be allocated?


A.

It prints: Error allocating memory


B.

It prints: Standard exception


C.

It prints: Unknown exception


D.

Compilation error


Get Premium CPA-21-02 Questions

Contribute your Thoughts:


Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.