1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Inheritance in C++

Discussion in 'C, C++, C#' started by Belen, Aug 2, 2013.

  1. Belen

    Belen Newbie

    Joined:
    Jul 26, 2013
    Messages:
    5
    Likes Received:
    0
    Occupation:
    engineer
    Location:
    Dallas
    Home Page:
    Can any one explain Inheritance in detail....
     
  2. sm754

    sm754 Registered Member

    Joined:
    Mar 21, 2012
    Messages:
    93
    Likes Received:
    38
    Occupation:
    Farmer
    Location:
    Azerbaijan
    If you're familiar with Java, it's like the "extends" keyword.
    Inheritance allows you to make a class that's based off another class known as the base class; a "Cat" class could inherit from a "Mammal" class (the Mammal class is the base of the Cat class), which would inherit from an "Animal" class, and so forth.
    A class can access the protected and public members of its base class, but not the private members.
     
    • Thanks Thanks x 1
  3. DeadMan12

    DeadMan12 Newbie

    Joined:
    May 30, 2013
    Messages:
    18
    Likes Received:
    0
    You need to go msdn
     
  4. seeplusplus

    seeplusplus Power Member

    Joined:
    Aug 18, 2008
    Messages:
    511
    Likes Received:
    163
    In inheritance, the class derived from the class above it inherits all the datamembers and functions of the class above it, and either uses them the same, or has it's own implementation of it.
     
  5. bartosimpsonio

    bartosimpsonio Jr. VIP Jr. VIP Premium Member

    Joined:
    Mar 21, 2013
    Messages:
    8,891
    Likes Received:
    7,493
    Occupation:
    ZLinky2Buy SEO Services
    Location:
    ⇩⇩⇩⇩⇩⇩⇩⇩⇩⇩⇩⇩
    Home Page:
    Inheritance is like copying all the stuff in the super classes into a new class, renaming it and then using it. Inheritance is there to avoid copying and pasting your preexisting code, in other words, to promote code reuse.
     
  6. nopme88

    nopme88 Registered Member

    Joined:
    Jul 30, 2013
    Messages:
    50
    Likes Received:
    7
    Occupation:
    Freelancer
    Inherited classes get all the properties of the parent. Also we can include new properties that are not in the parent.
     
  7. seoways

    seoways Jr. VIP Jr. VIP Premium Member UnGagged Attendee

    Joined:
    Dec 19, 2009
    Messages:
    4,659
    Likes Received:
    724
    Location:
    Behind you!
    Acquiring the properties of classes r class from other classes r class.
     
  8. morgan456

    morgan456 Jr. VIP Jr. VIP Premium Member

    Joined:
    Nov 26, 2010
    Messages:
    2,118
    Likes Received:
    247
    Gender:
    Male
    Occupation:
    SEO company
    Hope you need explanation with samples right...!