-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcode.cpp
More file actions
37 lines (33 loc) · 756 Bytes
/
code.cpp
File metadata and controls
37 lines (33 loc) · 756 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
#include<iostream>
using namespace std;
class A
{
private:
int a1, a2;
protected:
int pa1, pa2;
public:
void ppp(void)
{
cout<<"Value of pa1 of class A: "<<pa1<<endl;
cout<<"Value of pa2 of class A: "<<pa2<<endl;
}
}; // end of base class A
//derived class
class B : public A //protectedly-derived class
{
public:
void get(void)
{
cout<<"Enter value of pa1: "; cin>>pa1;
cout<<"Enter value of pa2: "; cin>>pa2;
cout<<"Value of pa1 of class A: "<<pa1<<endl;
cout<<"Value of pa2 of class A: "<<pa2<<endl;
}
}; // end of derived class B
int main()
{
B obj;
obj.get();
obj.ppp();
} // end of main() function