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 are containers in c++?

0 Answers  


What is the maximum combined length of command line arguments including the space between adjacent arguments?

0 Answers  


What it is and how it might be called (2 methods).

0 Answers  


What new()is different from malloc()?

0 Answers  


How is c++ different from java?

0 Answers  






How would you differentiate between a pre and post increment operators while overloading?

0 Answers  


What is the equivalent of Pascal's Real a) unsigned int b) float c) char

0 Answers  


Explain deep copy?

0 Answers  


What header file is needed for exit(); a) stdlib.h b) conio.h c) dos.h

0 Answers  


Describe private, protected and public?

0 Answers  


What is the Standard Template Library?

1 Answers  


What does scope resolution operator do?

0 Answers  


Categories