Question:
what are the advantages and disadvantages of inheritance?
Answer:
we can call many classes by using one class. for ex;;<br> class a1<br>{<br>int a;<br>public:<br>void get()<br>{<br>cout<<"<br>enter number";<br>cin>>a;<br>}<br>void dis()<br>{<br>cout<<"<br>number is"<<a;<br>}<br>};<br>class d1<br>{<br>int d;<br>public:<br>void get1()<br>{<br>get();<br>cout<<"enter number";<br>cin>>d;<br>}<br>void dis1()<br>{<br>dis()<br>cout<<"number is"<<d;<br>}<br>};<br>void main()<br>{<br>d dd;<br>dd.get1();<br>dd.dis1();<br>} Source: CoolInterview.com
Answered by: muthuraj | Date: 10/3/2008
| Contact muthuraj
advantage of inheritance is code reuse. Source: CoolInterview.com
Answered by: sanjeev | Date: 10/4/2008
| Contact sanjeev
Advantages :-<br>1. Code reusablitiy as the same base class could be used by many child classes adding their specific properties.<br>2. Accessbility, while inheriting a parent class the child class's declaration specifies the access ( public, private or protected ) .So, one could restrict the visibility of the parent class to enhance security.<br><br>Disadvantage:- <br><br>Unnecessarily adds complexity for very small programs. Source: CoolInterview.com
Answered by: manish | Date: 10/11/2008
| Contact manish
Advantages :- <br><br>Inheritance allows a subclass implementation to be defined in terms of parent class. Hence it allows code reuse and often known as White Box Reuse.<br><br>DisAdvantage :- <br><br>Subclass become dependent on parent class implementation. This makes it harder to use especially if part of inherited implementation is no longer available. Source: CoolInterview.com
Answered by: Aditya Agarwal | Date: 10/13/2008
| Contact Aditya Agarwal
Saves memory and user time: because same code need not to write again aand again.<br><br>Easy to understand: It's easy to understand large program with use of inheritence Source: CoolInterview.com
Answered by: Rashmi | Date: 12/13/2009
| Contact Rashmi
assignment of tipic inheitance .type ,meit and demeits Source: CoolInterview.com
Answered by: satend singh | Date: 6/12/2010
| Contact satend singh
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.
|