-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathoops.cpp
More file actions
105 lines (92 loc) · 1.04 KB
/
oops.cpp
File metadata and controls
105 lines (92 loc) · 1.04 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#include <bits/stdc++.h>
using namespace std;
class Base{
public:
Base()
{
cout<<"constructing base"<<endl;
}
static void Greet()
{
cout<<"HELLO FROM BASE"<<endl;
}
void GoodBye()
{
cout<<"GoodBye from base"<<endl;
}
~Base()
{
cout<<"destructing base"<<endl;
}
};
class Child:public Base{
int x,y;
public:
Child(int x,int y)
{
this->x=x;
this->y=y;
}
Child()
{
cout<<"constructing child"<<endl;
x=0;
y=0;
}
void SetValues(int x,int y)
{
this->x=x;
this->y=y;
}
static void Greet()
{
cout<<"HEllo from child"<<endl;
}
void GetValues()
{
cout<<x<<" "<<y<<endl;
}
void GoodBye()
{
cout<<"GoodBye from child"<<endl;
}
~Child()
{
cout<<"destructing child"<<endl;
}
};
// class Your;
class My{
public:
static int a;
static void f1();
};
int My::a;
class My1:private My{
public:
My1()
{
a=10;
}
My1(int x)
{
a=x;
}
void f1()
{
cout<<"A is"<<a<<endl;
}
};
void My::f1()
{
cout<<a<<endl;
}
int main()
{
My1 m;
// m.f1();
My1 m2(10);
m2.f1();
// cout<<m2.a;
return 0;
}