C++
  Home arrow C++ arrow Page 3 - Inheritance in C++
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
C++

Inheritance in C++
By: Gabor Bernat
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 3 stars3 stars3 stars3 stars3 stars / 2
    2009-06-09

    Table of Contents:
  • Inheritance in C++
  • Inheritance Types
  • Inheritance in General
  • Where to Use Protected
  • Constructor, Deconstructor

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Inheritance in C++ - Inheritance in General


    (Page 3 of 5 )

    These are key concepts in object-oriented programming. In addition, you should note that no constructors, deconstructors, or base class operators will be inherited, as these are too specific to work generally on the hierarchy tree constructed by an inheritance. Look over the iostream hierarchy tree shown below.

     

     

    This sums up the possibilities of inheritance inside C++ very well. The ios is the base class that holds common tasks for an input and output stream of data. These include details like where to store the data and how it is managed inside the stream.

    The istream and ostream are specifications of the ios and are considered derived classes from the ios base class. As you may conclude, multiple inheritance is also possible, and you can individually set their access inheritance specifies. For example, you can set one public and the other protected (remember this is only for example purposes; this is implemented differently in the iostream library):

     

    class iostream: public istream, protected ostream

    {

    // …

    };

     The method is to split them with a comma and specify for each of them what type of inheritance to execute. Remember that if you leave this empty, it's private inheritance by default. Multiple inheritances should be used carefully and only by experienced programmers, as they tend to be a little more complicated to maintain and code correctly.

    The iostream class is the direct derived class of both the istream and ostream classes. If you climb up further in the hierarchy tree, the ios class is the indirect base of the iostream class.

    More C++ Articles
    More By Gabor Bernat


       · Please do not use inheritance for code reuse! Inheritance for code reuse leads to...
       · Thanks for your comment, As usual the coin has two sides. And you just touched...
     

    C++ ARTICLES

    - More Tricks to Gain Speed in Programming Con...
    - Easy and Efficient Programming for Contests
    - Preparing For Programming Contests
    - Programming Contests: Why Bother?
    - Polymorphism in C++
    - Overview of Virtual Functions
    - Inheritance in C++
    - Extending the Basic Streams in C++
    - Using Stringstreams in C++
    - Custom Stream Manipulation in C++
    - General Stream Manipulation in C++
    - Serialize Your Class into Streams in C++
    - Advanced File Handling with Streams in C++
    - File Handling and Streams in C++
    - The STL String Class







    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 5 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek