Forum

Inheritance In C++

This thread contains 3 replies, has 4 voices, and was last updated by Bhasker Nimi 5 years, 7 months ago.

  • Author Replies
    • #55611

      How Many Types of Inheritance Are There In C++ Programming Language?


    • #55613

      There are 5 types of Inheritance in C++.

      1) Single Inheritance
      2) Multiple Inheritance
      3) Hierarchical Inheritance
      4) Multilevel Inheritance
      5) Hybrid Inheritance (also known as Virtual Inheritance)


      Regards,
      Nitesh Bavishiya

    • #58190

      The capability of a class to derive properties and characteristics from another class is called Inheritance. Inheritance is one of the most important feature of Object Oriented Programming.
      Sub Class: The class that inherits properties from another class is called Sub class or Derived Class.
      Super Class:The class whose properties are inherited by sub class is called Base Class or Super class.

      // C++ program to demonstrate implementation
      // of Inheritance

      #include <bits/stdc++.h>
      using namespace std;

      //Base class
      class Parent
      {
      public:
      int id_p;
      };

      // Sub class inheriting from Base Class(Parent)
      class Child : public Parent
      {
      public:
      int id_c;
      };

      //main function
      int main()
      {

      Child obj1;

      // An object of class child has all data members
      // and member functions of class parent
      obj1.id_c = 7;
      obj1.id_p = 91;
      cout << “Child id is ” << obj1.id_c << endl;
      cout << “Parent id is ” << obj1.id_p << endl;

      return 0;
      }

      OUTPUT:
      Child id is 7
      Parent id is 91

      To know more about this visit at: http://www.cetpainfotech.com/technology/C-Language-Training


    • #58664

      c is a basic programing language. this is help to us to read any language


      Attachments (Allowed file type: .jpg, .jpeg, .png, .pdf):
      You must be logged in to view attached files.
Viewing 3 reply threads

You must be to reply to this thread.Please or . Registration is 100% free.

GET FREE CONSULTATION

Call Us Now For Free Consultation97370 05566

Our experts listen to you patiently and suggest you the right course after conducting a personality profile test. Register your interest below to schedule personality profile test for you.

SUBSCRIBE TO OUR NEWSLETTER

Subscribe to get latest updates regarding courses, IT industry and career prospects.

Copyright 2016-2024 Smart Mentors. All Rights Reserved.

Login

FORGOT PASSWORD

Sign up now to Become An Instructor

    Register your Interest

      cf7captchaRegenerate Captcha