class professor {};
class teacher : public virtual professor {};
class researcher : public virtual professor {};
class myprofessor : public teacher, public researcher {};

Referring to the sample code above, if an object of class
"myprofessor" were created, how many instances of professor
will it contain?
a) 0
b) 1
c) 2
d) 3
e) 4

Answers were Sorted based on User's Feedback



class professor {}; class teacher : public virtual professor {}; class researcher : public virtu..

Answer / guest

Ans is value 1 i.e ans B

Is This Answer Correct ?    22 Yes 0 No

class professor {}; class teacher : public virtual professor {}; class researcher : public virtu..

Answer / ahsanullah

becouse of virtual keyword it will create only one instances,
so ANS is: 1

Is This Answer Correct ?    6 Yes 0 No

class professor {}; class teacher : public virtual professor {}; class researcher : public virtu..

Answer / d.sakthi

ans is 1 option b
reason:as three classes are derived from base class single instance is enough

Is This Answer Correct ?    3 Yes 0 No

class professor {}; class teacher : public virtual professor {}; class researcher : public virtu..

Answer / alliance group

answer is 1......b option

Is This Answer Correct ?    2 Yes 0 No

Post New Answer

More C++ General Interview Questions

What is iomanip c++?

0 Answers  


What are enumerations?

0 Answers  


What is c++ library?

0 Answers  


In a class, there is a reference or pointer of an object of another class embedded, and the memory is either allocated or assigned to the new object created for this class. In the constructor, parameters are passed to initialize the data members and the embedded object reference to get inialized. What measures or design change should be advised for proper destruction and avioding memory leaks, getting pointers dangling for the embedded object memory allocation? Please suggest.

5 Answers   GE,


Can you please explain the difference between using macro and inline functions?

0 Answers  






What is a character in c++?

0 Answers  


Is c++ slower than c?

0 Answers  


Why did you leave your last job?

2 Answers  


What is optimization in c++? when using volatile.optimization is not possible..what does this mean?

1 Answers  


Is std :: string immutable?

0 Answers  


What is nested class in c++?

0 Answers  


What are default parameters? How are they evaluated in c++ function?

0 Answers  


Categories