-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCODE35.cpp
More file actions
55 lines (54 loc) · 1.1 KB
/
CODE35.cpp
File metadata and controls
55 lines (54 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include<iostream> //MAKING CONSTRUCTOR IN DERIVED CLASS
using namespace std;
class Base1
{
int Data1;
public:
Base1(int a)
{
Data1=a;
cout<<"this is me Base1 constructor......"<<endl;
}
void Getdata1(void)
{
cout <<"Base 1 this is your data "<<Data1<<endl;
}
};
class Base2
{
int Data2;
public:
Base2(int a)
{
Data2=a;
cout<<"this is me virtual base constructor......"<<endl;
}
void Getdata2(void)
{
cout <<"Base2 this is your data "<<Data2<<endl;
}
};
class Derived : public Base1,virtual public Base2
{
int derived;
public:
Derived(int a, int b,int c);
void GetdataDerived(void);
};
void Derived ::GetdataDerived(void)
{
cout<<"this is your data of Derived int "<< derived;
}
Derived:: Derived(int a, int b,int c): Base1(a), Base2(b)
{
derived = c;
cout<<"this is me Derived class constructor......"<<endl;
}
int main()
{
Derived a1(1,2,3);
a1.Getdata1();
a1.Getdata2();
a1.GetdataDerived();
return 0;
}