-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path41.cpp
52 lines (46 loc) · 943 Bytes
/
41.cpp
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
//Single Inheritance.
#include<iostream>
using namespace std;
class parent
{
private:
void fun1()
{
cout<<"This is fun1 function";
}
public:
void fun2()
{
cout<<"This is fun2 function";
}
};
/* class childclassname : access_specifier parentclassname*/
class child1 : private parent // syntax of inheritance
{
// fun1 will not be inherited
// fun2 will be inherited in private section of child1 class
};
class child2 : public parent
{
public:
void fun3()
{
cout<<"\nThis is fun3 function";
}
// fun1 will not be inherited
// fun2 will be inherited in public section of child1 class
};
int main()
{
// parent p;
// p.fun1();
// p.fun2();
/* child1 c1;
c1.fun1();
c1.fun2();*/
child2 c2;
// c2.fun1();
c2.fun2();
c2.fun3();
return 0;
}