how can I Inherit from 2 classes?

how can I Inherit from 2 classes

I have 3 classes

derive 1 , derive 2, derive 3;
derive 2 Inherit from derive 1;
derive 3 also Inherit from derive 1 and derive 2;
derive 3 It includes a constructor and a display function that calls the display functions of the parents.

I did all at above
but ;
I do not know how can I Inherit from derive 1 and derive 2?
Last edited on
derive 2 have 4 argument
derive 2 have 2 argument;
if derived 3 inherits fom derived 2 it will also inherits fom derived 1 , since derived 2 inherits from derived 1. the moment this is not true is if derived 2 private inherits from derived 1.

this is my code,
can you show me in action please
I did tray it put, it is take an error for me

----------------------------------------------------------------------------------------
#include<iostream>
#include<string>
using namespace std;
class derive1
{
public:
int initial;
int current ;
int profit;
int percent;
public:
derive1(){initial = 0, current = 0 , profit = 0, percent = 0;}
derive1(int i , int c, int p , int pe)
{initial = i;
current = c;
profit = p;
percent = pe;
}


};
class derive2 : public derive1
{
public:
string street;
int square;
public:
derive2 (){street = ""; square = 0;}
derive2 ( int i , int c, int p , int pe ,string s,int sq):derive1(i ,c , p , pe)
{street = s;
square = sq;
}


};

class derive3
{



};
http://www.cplusplus.com/articles/z13hAqkS/


Please always use code tags.

If you have compiler errors then post them here exactly and in full. Make sure the line numbers match up with your code that has the code tags.

Public inheritance implies an "IS A" relationship. It doesn't look like that is the case in your code - you may not need inheritance at all.

Good Luck !!

I do not understand it!!!
my teacher said like this
but , I did not understand it at yet
it is a new idea for me

I hope to do it in the code
for understand me
if you please .
you need to call base constructor in derived constructor... i cannot write the code right now i am using an ipad..
did you mean this?


class derive3:public derive2
{
public:
derive3 derive2( int i , int c, int p , int pe ,string s,int sq);


};



this is what I understood it
is it valid or not?
help me please I need it today .
Last edited on
Finally I found it;
thank you @Ericool
ur welcome
Topic archived. No new replies allowed.