Sail E0 Webinar
Question


What is the output of this program?


1.
#include
2.
#include
3.
#include
4.
using namespace std;
5.
class base
6.
{
7.
virtual void f(){}
8.
};
9.
class derived : public base {};
10.
int main ()
11.
{
12.
try
13.
{
14.
base* a = new base;
15.
base* b = new derived;
16.
cout
Options:
A .  base*
B .  derived*
C .  4base and 7derived
D .  None of the mentioned
Answer: Option C

In this program, We apply the typeid to the polymorphic class.
Output:
$ g++ rtti2.cpp
$ a.out
4base 7derived



Was this answer helpful ?
Next Question

Submit Solution

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

Latest Videos

Latest Test Papers