forked from Backslash-Computing-Society/Hacktober
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path5_2.cpp
More file actions
53 lines (52 loc) · 650 Bytes
/
5_2.cpp
File metadata and controls
53 lines (52 loc) · 650 Bytes
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
#include<iostream>
#include<cstring>
using namespace std;
class x{
char a[50];
public:
x(char* str)
{
strcpy(a,str);
}
void xdisp()
{
cout<<"x is: "<<a<<endl;
}
};
class y{
char b[50];
public:
y(char* str)
{
strcpy(b, str);
}
void ydisp()
{
cout<<"y is: "<<b<<endl;
}
};
class z: public x,public y{
char c[50];
public:
z(char* s,char* t):x(s),y(t)
{
strcat(s,t);
strcpy(this->c,s);
}
void zdisp()
{
cout<<"z is: "<<c<<endl;
}
};
int main()
{
char str1[]="Hello ";
char str2[]="World";
z ob(str1,str2);
ob.xdisp();
cout<<endl;
ob.ydisp();
cout<<endl;
ob.zdisp();
return 0;
}