Jump to content
Urch Forums

Inheritances


AlbaLed

Recommended Posts

 

[*]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

Link to comment
Share on other sites

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 ?

Link to comment
Share on other sites

"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.

Link to comment
Share on other sites

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?

 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...