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

Table of Contents

  • Multiple inheritances in C++ language
    • Related

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

  • Multiply two numbers in Java using scanner| 5 different ways
  • 5 different ways to Divide two numbers in Java using scanner
  • Learn 8 Ways to Subtract Two Numbers Using Methods in Java
  • 10 ways to subtract two numbers in Java
  • Java Code Examples – Multiply Two Numbers in 5 Easy Ways
  • How to Divide two numbers in Java| 5 different ways

tag

Addition (8) Array (38) C++ language (91) C language (98) c sharp (23) Division (8) Function (29) if else (32) Java language (108) JavaScript (5) loops (138) Multiply (8) Oop (2) patterns (66) PHP (13) Python Language (38) Subtraction (9) temperature (20)

Archives

Categories

Address

Global information technology

Puloly south, PointPedro

Jaffna

Srilanka

©2026 Code for Java c | Powered by SuperbThemes