What will happen if we use the operator “new” and the memory cannot be allocated?
Given:
#include <iostream>
#include <exception>
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
Answer: A
Latest CPA-21-02 Dumps Valid Version with 222 Q&As
Latest And Valid Q&A | Instant Download | Once Fail, Full Refund
Subscribe
Login
0 Comments
Inline Feedbacks
View all comments