forked from codebloded/BackToBasics.cpp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathderivedClassConst.cpp
More file actions
56 lines (51 loc) · 1.22 KB
/
derivedClassConst.cpp
File metadata and controls
56 lines (51 loc) · 1.22 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
56
#include<iostream>
using namespace std;
class First{
private:
int var1;
public:
First(int x){
var1 =x;
cout<<"The First class constructor is called"<<endl;
}
void printFirst(void){
cout<<"The vaue of var1 is: "<<var1<<endl;
}
};
class Second{
private:
int var2;
public:
Second(int y){
var2 = y;
cout<<"The class Second constructor is called "<<endl;
}
void printSecind(void){
cout<<"The value of var2 is: "<<var2<<endl;
}
};
class Derived: public First , public virtual Second{
private:
int var3 ,var4;
public:
Derived(int a, int b , int c , int d):First(a) , Second(b){
var3 = c;
var4 = d;
cout<<"The derived class constructor is called "<<endl;
}
void displayderived(void)
{
cout<<"The value od var3 and var4 is :"<<var3<<" "<<var4<<endl;
}
};
int main()
{
int p,q,r,s;
cout<<"Enter the values to be passed o the constructor "<<endl;
cin>>p>>q>>r>>s;
Derived rohan(p,q,r,s);
rohan.printFirst();
rohan.printSecind();
rohan.displayderived();
return 0;
}