Skip to content
Menu
Code for Java c
  • Home
  • Java
    • Java Examples
    • Java tutorials
  • C
    • C tutorials
    • C Examples
  • C++
    • C++ Tutorials
    • C++ Examples
  • Python
    • Python Tutorials
    • Python Examples
  • About
    • About me
    • contact us
    • disclaimer
    • Privacy Policy
Code for Java c

Multiple inheritance in C++ language

Posted on February 18, 2017January 21, 2020

Multiple inheritances in C++ language

In this tutorial, we will discuss the OOP concept of multiple inheritances in C++ language.
Inheritance is the process of inheriting data members and methods of one class by another class. When a class is derived from two or more base class, it is called multiple inheritance. Multiple inheritance is a feature of the object-oriented programming language of C++.
In C++, a child class can inherit from more than one parent class. Multiple inheritance is not support in Java.

"Multiple

Syntex

"Multiple

 

Ex

class A

{

””””””””””””””””

};

class B{

………………………

}

class C access_specifier A, acces_Specifier B//inherit properties from classes A and B



Program 1

"Multiple

Explanation is above program

#include <iostream>
using namespace std;
class cost //start of class cost
{
protected://access modifier – protected
int cp;
public://access modifier – public
void getcp()
{
cout << “Enter the cost prize:” << endl;
cin >>cp;
}
}; //end of class cost
class sell
{  //start of class sell
protected:  //access modifier – protected
int sp;
public:
void getsp()
{
cout << “Enter the selling prize:” << endl;
cin >>sp;
}
};  //end of class sell

class profit:cost,sell
{ //start of class profit and which is inherits property from parant class cost, sell
private:    //access modifier – private
int pf;
public:  //access modifier – public
void profits()
{
getcp();
getsp();
pf=sp-cp;
cout << “profit is:” <<pf<<endl;
cin >>sp;
}
}; //end of class profit
int main()
{
profit o; //create object for class profit
o.profits();  //call method profit through object
return 0;
}

 

Similar post

 Inheritance in Java                     Inheritance in C++           Interface in Java      
 
 Single level inheritance in java               Single level inheritance in C++
 
Multi level inheritance in Java                    Multilevel inheritance in C++
Multiple Inheritance in C++
Hierarchical Inheritance in Java
 
          

Related

Recent Posts

  • Subtract two numbers using method overriding
  • PHP Star triangle Pattern program
  • Using function or method to Write temperature conversion : Fahrenheit into Celsius
  • Function or method:temperature conversion from Fahrenheit into Celsius – Entered by user
  • Write temperature conversion program: Fahrenheit into Celsius
  • How to write a program to convert Fahrenheit into Celsius

tag

Addition (6) Array (38) C++ language (91) C language (98) c sharp (23) Division (6) Function (29) if else (32) Java language (102) JavaScript (5) loops (137) Multiply (7) Oop (2) patterns (65) PHP (13) Python Language (38) Subtraction (7) temperature (20)

Archives

Categories

Address

Global information technology

Puloly south, PointPedro

Jaffna

Srilanka

©2025 Code for Java c | Powered by SuperbThemes