What happens if character 3 is entered as input?

What happens if character 3 is entered as input?

#include <iostream>

using namespace std;

class A {

public:

int i;

};

int main () {

int c;

A obj;

obj.i = 5;

cin >> c;

try

{

switch (c)

{

case A. throw 20;

case B. throw 5.2f;

case C. throw obj;

default: cout<<"No exception";

}

}

catch (int e)

{ cout << "int exception. Exception Nr. " << e; }

catch (A e)

{ cout << "object exception. Exception Nr. " << e.i; }

catch (…)

{ cout << "An exception occurred."; }

return 0;

}

A. It prints: object exception. Exception Nr. 5

B. It prints: int exception. Exception Nr.

C. It prints: An exception occurred

D. It prints: No exception

Answer: A

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments