Question
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
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
Answer: Option C
Was this answer helpful ?
In this program, We apply the typeid to the polymorphic class.
Output:
$ g++ rtti2.cpp
$ a.out
4base 7derived
Was this answer helpful ?
More Questions on This Topic :
Question 2.
Which operators are part of RTTI?
....
Question 4.
To which type of class, We can apply RTTI?
....
Question 5.
What is the Run-Time Type Information?
....
Submit Solution