Question
1.
#include
2.
#include
3.
using namespace std;
4.
class Polymorphic {virtual void Member(){}};
5.
int main ()
6.
{
7.
try
8.
{
9.
Polymorphic * pb = 0;
10.
typeid(*pb);
11.
}
12.
catch (exception& e)
13.
{
14.
cerr
What is the output of this program?
1.
#include
2.
#include
3.
using namespace std;
4.
class Polymorphic {virtual void Member(){}};
5.
int main ()
6.
{
7.
try
8.
{
9.
Polymorphic * pb = 0;
10.
typeid(*pb);
11.
}
12.
catch (exception& e)
13.
{
14.
cerr
Answer: Option A
Was this answer helpful ?
In this program, We used a bad type id for the polymorphic operator, So it is arising an
bad_typeid exception.
Output:
$ g++ etae.cpp
$ a.out
exception caught: std::bad_typeid
Was this answer helpful ?
Submit Solution