Sail E0 Webinar
Question


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
Options:
A .  exception caught: std::bad_typeid
B .  exception caught: std::bad_alloc
C .  exception caught: std::bad_cast
D .  none of the mentioned
Answer: Option A

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 ?
Next Question

Submit Solution

Your email address will not be published. Required fields are marked *

Latest Videos

Latest Test Papers