1.

What is the output of this program?
#include <iostream>
using namespace std;
class BaseClass
{
protected:
int num;
public:
BaseClass()
{
num = 25;
}
BaseClass(int k)
{
num = k;
}
virtual ~BaseClass()
{
if (num < 0) throw num;
}
virtual int getA()
{
if (num < 0)
{
throw num;
}
}
};
int main()
{
try
{
BaseClass obj(-23);
cout << endl << obj.getA();
}
catch (int)
{
cout << endl << "Illegal initialization";
}
}

A. Runtime Error
B. Compilation Error
C. Illegal initialization
D. Garbage value
E. None of these
Answer» C. Illegal initialization


Discussion

No Comment Found

Related MCQs