AlbaLed Posted November 3, 2003 Share Posted November 3, 2003 There are two types of inheritances, interface inheritance and implmentation inheritance. Define their differences. Define their advantages and disadvantages? Quote Link to comment Share on other sites More sharing options...
wood Posted November 3, 2003 Share Posted November 3, 2003 [*]Interface inheritance models "is-a'' relationships. This means that a derived class can perform all actions the base class can perform. The derived class may add further methods; however, it cannot remove methods. The derived class may alter the how actions are done. Interface inheritance creates subtype - supertype relations. [*]Implementation inheritance makes the (non-private) methods of the base class available for the derived class. In C++ the implementation is automatically inherited whenever the interface is inherited; pure implementation inheritance is also possible using a private base class. This is a "uses'' relationship. It is a rarely used technique. From this link Quote Link to comment Share on other sites More sharing options...
AlbaLed Posted November 3, 2003 Author Share Posted November 3, 2003 Interface inheritances could detrement performance if they are the only form of inheritance supported. While implementation inheritances have a more serious flaw, suppose we change the superclass, and delete a variable used by all the subclasses then when the programs are compiled a nice-not-easy-to-find error is created. Solution ?? Simple, support both, let the programmer do the decision. One more Are subclasses subtypes ? Quote Link to comment Share on other sites More sharing options...
wood Posted November 3, 2003 Share Posted November 3, 2003 Nope... Check this out. Quote Link to comment Share on other sites More sharing options...
AlbaLed Posted November 3, 2003 Author Share Posted November 3, 2003 "Nevertheless, we note that most existing object-oriented programming languages do identify type and class as well as subtype and subclass. That is, a class is identified with the type of objects it generates, while only subclasses generate subtypes", Quote from your link. Quote Link to comment Share on other sites More sharing options...
AlbaLed Posted November 3, 2003 Author Share Posted November 3, 2003 wood any thoughts on this?? Quote Link to comment Share on other sites More sharing options...
wood Posted November 3, 2003 Share Posted November 3, 2003 As mentioned at the beginning of the paragraph, there's a clear theoretical difference between subclasses and subtypes. However, some languages might just treat the concepts as one and the same, providing what inheritance and subtyping capabilities it supports. Did I misunderstand anything? Quote Link to comment Share on other sites More sharing options...
AlbaLed Posted November 3, 2003 Author Share Posted November 3, 2003 In order to be a subtype, the methods of the subclass must satisfy the superclass's specifications. That is if a correct "is-a" relationship holds that's when a subclass can be called a subtype. Subclasses can be subtypes if they are well behaved, for example if you subclass a class called PlanarShape which provides Area() and make a Cube where Area() returns volume, there is no subtyping because a Cube "is not a" (not "is-a")PlanarShape. check this link out it seems good http://6170.lcs.mit.edu/www-archive/Old-2001-Spring/recitations/recitation4.html Quote Link to comment Share on other sites More sharing options...
Vinay Posted November 3, 2003 Share Posted November 3, 2003 well thr r so many different concepts regarding inheritance lying thr but basic remains tht supertype-subtype one. the thing is tht ETS cannot provide us questions tht can have multiple definations like inheritance,parameter passing etc. though if they refer to these topics I think they will definately focus on things tht r very general or otherwise a question can become ambiguous. The best thing tht they do is tht they define wht they r talking abt in questions so you know wht they r talking abt. this is evident frm the practice test. Quote Link to comment Share on other sites More sharing options...
wood Posted November 3, 2003 Share Posted November 3, 2003 Thanks for the link AlbaLed.. now it seems clear. Yeah Vinay.. I agree with you. Sometimes we go a little overboard in a discussion, however, that doesn't hurt us much. We will never forget about the subject now. Wood Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.