-
Notifications
You must be signed in to change notification settings - Fork 0
/
oop.cpp
51 lines (49 loc) · 1.07 KB
/
oop.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
#include<bits/stdc++.h>
using namespace std;
class student
{
public:
int id;
double gpa;
};
class details
{
public:
int age;
int semister;
//using fuction or medhod
void display()
{
cout<< "AGE: "<<age<<" "<<"SEMISTER: " <<semister <<endl;
}
//using fuction or medhod
void input()
{
cout<<"AGE: "<< endl;
cin>>age;
cout<<"SEMISTER: "<<endl;
cin>>semister;
}
//adding parametrized function to the class
void set_value(int x, int y)
{
age=x;
semister=y;
}
};
int main()
{
student jit,prosenjit;
details roy;
jit.id=68;
jit.gpa=3.95;
prosenjit.id=69;
prosenjit.gpa=4;
cout<< "ID: "<<jit.id<<" "<<"Gpa: " <<jit.gpa <<endl;
cout<< "ID: "<<prosenjit.id<<" "<<"Gpa: " <<prosenjit.gpa <<endl;
roy.input();
roy.display();
roy.set_value(22,5);
roy.display();
return 0;
}