GeekInterview.com
   Home |  Tech FAQ  |   Interview Questions |  Placement Papers |  Tech Articles |  Learn |  Freelance Projects |  Online Testing |  Geeks Talk |  Job Postings |  Knowledge Base | Site Search |  Add/Ask Question

  GeekInterview.com  >  Interview Questions  >  Programming  >  C++

 Print  |  
Question:  Inheritance

Answer: Which one of the following statements regarding C++ class inheritance is FALSE?

a. Inheritance promotes generic design and code reuse.
b. Struct cannot be inherited in C++.
c. C++ supports multiple inheritance.
d. Inheritance is a mechanism through which a subclass inherits the properties and behavior of its superclass.

 


September 09, 2009 12:52:10 #9
 Master Sargent   Member Since: September 2009    Total Comments: 1 

RE: Inheritance
 

The only difference between a class and a struct is a class has private access and private inheritance by default and a struct has public access and public inheritance by default. The only place I'm aware of that you can't replace class with struct is in a template definition. For example, template, where you can also use template, but template is incorrect.


struct is a class keyword and anything you can do with a class you can do with struct. Virtual functions, pure virtual functions, inheritance, data member initialization all of it, there aren't any restrictions. You could literally go through a program and replace every instance of class, except as noted previously, with the equivalent struct definition.


     

 

Back To Question