-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOOPs2.c++
47 lines (35 loc) · 906 Bytes
/
OOPs2.c++
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
#include <iostream>
using namespace std;
class Student {
public:
string branch;
string name;
int rollNo;
Student() {
branch = "mechanical";
name = "Aditya Rai";
rollNo = 22135011;
}
Student(string branch, string name, int rollNo) {
this->branch = branch;
this->name = name;
this->rollNo = rollNo;
}
void print(){
cout<<" The name of branch is: "<< this->branch << endl;
cout<<" The name of student is: "<< this->name << endl;
cout<<" The rollNo of student is: "<< this->rollNo << endl;
}
};
int main() {
Student Aditya;
Student Abhinav("Electronics", "Abhinav", 22135008);
Student Avipsa(Abhinav);
Avipsa.name = "Avipsa";
Avipsa.branch = "Mechanical";
Avipsa.rollNo = 22135035;
Aditya.print();
Abhinav.print();
Avipsa.print();
return 0;
}