TODAY JAVA SCHOOL

In java school, programming, design, computer general knowledge, web application, software, web services, social media, digital marketing, oops, concept of programming language, oops feature, console media, graphics medium, first programming, c, c ++ , Java, PHP, SQL, MySQL, HTML, HTML_5, J_query, JavaScript, Bootstrap, Framework, images with logos, examples, shared and explained.

https://www.amazon.in/b?node=26373545031&linkCode=ll2&tag=1234567801cdb-21&linkId=3b9882431b00409b44141e0344b35a15&language=en_IN&ref_=as_li_ss_tl

Breaking

Saturday, 29 August 2020

Inheritance in C++| Explain Inheritance in C++| Example Of Inheritance in C++| Program Of Inheritance in C++ | Syntax Of Inheritance in C++| Inheritance in C++ In Hindi

Inheritance in C++ 

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.

Features Of Inheritance

•    Dimension values, tolerances, and boundaries

•    Geometry tolerances (part of Annotations)

•    Parameters

     References 

    Suppressed, resumed or erased state of features 

   Annotations

     

image of Inheritance in C++

Fig:Inheritance in C++


Super Class:

The class whose properties are inherited by sub class is called Base Class or Super class.

Syntax:

              class baseclassname

               {

private:

datamember;

public:

datamember;

member function;

};


Sub Class:

 The class that inherits properties from another class is called Sub class or Derived Class.

Syntax:

          class  derivedclassname :visibilitymode  baseclassname

               {

private:

datamember;

public:

datamember;

member function;

};

 

Program:

#include<iostream.h>

#include<conio.h>

class base

{

public:

void display()

{

cout<<”base class created”<<endl;

}

};

class derived: public base

{

 public:

void display1()

{

cout<<”derived class created”<<endl;

}

};

void main()

{

Derived a1;

a1.display();

a1.display1();

getch();

}


Output:

Base class created

Derived class created

 
Implementing inheritance in C++
:

For creating a sub-class which is inherited from the base class.

Syntax:

class subclass_name:access_mode base_class_name

{

//body of subclass

}

 

Modes of Inheritance

 

1.   Public mode:

 

If we derive a sub class from a public base class. Then the public member of the base class will become public in the derived class and protected members of the base class will become protected in derived class.

 

2.   Protected mode:

 

 If we derive a sub class from a Protected base class. Then both public member and protected members of the base class will become protected in derived class.

 

3.   Private mode:

 If we derive a sub class from a Private base class. Then both public member and protected members of the base class will become Private in derived class.

 

No comments:

Post a Comment