-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclass2.cpp
More file actions
executable file
·96 lines (85 loc) · 1.91 KB
/
Copy pathclass2.cpp
File metadata and controls
executable file
·96 lines (85 loc) · 1.91 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
#include<iostream>
using namespace std;
class A
{
private:
int a1, a2;
protected:
int pa1, pa2;
public:
int b;
void ppp(void)
{
cout<<"Value of pa1 of class A: "<<pa1<<endl;
cout<<"Value of pa2 of class A: "<<pa2<<endl;
//cout<<"Value of b of class A: "<<b<<endl;
}
}; // end of base class A
//derived class
class B : public A //publicly-derived class
{
public:
void get(void)
{
cout<<"Enter value of pa1: "; cin>>pa1;
cout<<"Enter value of pa2: "; cin>>pa2;
}
}; // end of derived class B
int main()
{
B obj;
//int a= obj.b=100;
//cout<<"Value of a is: "<<a<<endl;
obj.get();
obj.ppp();
} // end of main() function
/*
class student
{
private:
char name[15], address[15];
int id;
public:
void input(void)
{
cout<<"Enter your name: ";
cin>>name;
cout<<"Enter address:";
cin>>address;
}
void show(void)
{
cout<<"Name is: "<<name<<endl;
cout<<"Address is :"<<address<<endl;
}
}; // end of base class student
//derived class
class marks : public student
{
private:
int s1,s2,s3,s4,total;
public:
void inputmarks(void)
{
cout<<"Enter marks of sub1: ";cin>>s1;
cout<<"Enter marks of sub2: ";cin>>s2;
cout<<"Enter marks of sub3: ";cin>>s3;
total= s1+s2+s3;
}
void show_detail(void);
}; // end of derived class marks
int main()
{
marks mmm;
mmm.input();
mmm.inputmarks();
mmm.show_detail();
} // end of main() function
void marks :: show_detail()
{
show();
cout<<"Marks of 1st subject: "<<s1<<endl;
cout<<"Marks of 2nd subject: "<<s2<<endl;
cout<<"Marks of 3rd subject: "<<s3<<endl;
cout<<"Total Marks : "<<total<<endl;
}*/