-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathBasic inheritance.cpp
More file actions
72 lines (67 loc) · 1.07 KB
/
Copy pathBasic inheritance.cpp
File metadata and controls
72 lines (67 loc) · 1.07 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
#include <iostream>
#include <string>
using namespace std;
class members
{
public:
members()
{
cout << "class 'members' created" << endl;
ID = 0;
name = "NULL";
}
void get_name(string myName)
{
name = myName;
cout << "Name is: " << name << endl;
}
void get_ID(int myID)
{
ID = myID;
cout << "ID is: " << ID << endl;
}
~members()
{
cout << "class 'members' destroyed" << endl;
}
private:
int ID;
string name;
};
class student : public members
{
public:
student()
{
cout << "class 'students' created" << endl;
gpa = 0;
_class = "NULL";
}
void get_gpa(float myGpa)
{
gpa = myGpa;
cout << "GPA is: " << gpa << endl;
}
void get_class(string myClass)
{
_class = myClass;
cout << "Class is: " << _class << endl;
}
~student()
{
cout << "class 'student' destroyed" << endl;
}
private:
float gpa;
string _class;
};
int main()
{
student p1;
p1.get_name("Tahoor");
p1.get_ID(240592);
p1.get_class("MTS-39");
p1.get_gpa(3.6);
system("pause");
return 0;
}