|
INTERVIEW QUESTIONS
C++
INHERITANCE IN C++
DETAILS
Question: Explain the ISA and HASA class relationships. How would you implement each in a class design?
Answer: A specialized class "is" a specialization of another class and, therefore, has the ISA relationship with the other class. An Employee ISA Person. This relationship is best implemented with inheritance. Employee is derived from Person. A class may have an instance of another class. For example, an employee "has" a salary, therefore the Employee class has the HASA relationship with the Salary class. This relationship is best implemented by embedding an object of the Salary class in the Employee class.
|
|
|
Category |
Inheritance in C++ Interview Questions & Answers -
Exam Mode /
Learning Mode
|
Rating |
(0.2) By 8213 users |
Added on |
9/16/2014 |
Views |
67182 |
Rate it! |
|
|
Question:
Explain the ISA and HASA class relationships. How would you implement each in a class design?
Answer:
A specialized class "is" a specialization of another class and, therefore, has the ISA relationship with the other class. An Employee ISA Person. This relationship is best implemented with inheritance. Employee is derived from Person. A class may have an instance of another class. For example, an employee "has" a salary, therefore the Employee class has the HASA relationship with the Salary class. This relationship is best implemented by embedding an object of the Salary class in the Employee class. Source: CoolInterview.com
If you have the better answer, then send it to us. We will display your answer after the approval.
Rules to Post Answers in CoolInterview.com:-
- There should not be any Spelling Mistakes.
- There should not be any Gramatical Errors.
- Answers must not contain any bad words.
- Answers should not be the repeat of same answer, already approved.
- Answer should be complete in itself.
|
|
Related Questions |
View Answer |
|
When should you use multiple inheritance?
|
View Answer
|
|
What do you mean by inheritance?
|
View Answer
|
|
Does c++ support multilevel and multiple inheritance?
|
View Answer
|
|
What are the advantages of inheritance?
|
View Answer
|
|
Virtual constructor: Constructors cannot be virtual. Declaring a constructor as a virtual function is a syntax error. Does c++ support multilevel and multiple inheritance?
|
View Answer
|
|
Can we include music/song in background while running a program like a game in c++ ?
|
View Answer
|
|
What does inheritance means in C++? What are the different forms of inheritance? Give an example for each.
|
View Answer
|
|
what are the advantages and disadvantages of inheritance?
|
View Answer
|
|
Why Call by reference technique is used in case of Copy constructor & not call by value?
|
View Answer
|
|
What is the difference between composition and inheritance?
|
View Answer
|
|
What Is The Use of VirtualDestructer?
|
View Answer
|
|
Is there any way to write a class such that no class can be inherited from it. Please include code
|
View Answer
|
|
What do you mean by inheritance?
|
View Answer
|
|
class A() { };
int main() { A a; }
Whether there will be a default constructor provided by the compiler in above case ?
|
View Answer
|
|
what is the use of volatile keyword? Give me one example?
|
View Answer
|
|
it possible to inherit the private member in drived class?
|
View Answer
|
|
Can you prevent your class from being inherited and becoming a base class for some other classes?
|
View Answer
|
|
Can you allow class to be inherited, but prevent the method from being over-ridden?
|
View Answer
|
|
Can you inherit multiple interfaces?
|
View Answer
|
|
If a base class has a bunch of overloaded constructors, and an inherited class has another bunch of overloaded constructors, can you enforce a call from an inherited constructor to an arbitrary base constructor?
|
View Answer
|