-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path5b.cpp
More file actions
44 lines (36 loc) · 913 Bytes
/
Copy path5b.cpp
File metadata and controls
44 lines (36 loc) · 913 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
38
39
40
41
42
43
44
#include <iostream>
using namespace std;
class Student {
private:
int id;
string name;
public:
Student() {
id = 0;
name = "Unknown";
cout << "Default constructor called." << endl;
}
Student(int i) {
id = i;
name = "Unknown";
cout << "Constructor with 1 parameter called." << endl;
}
Student(int i, string n) {
id = i;
name = n;
cout << "Constructor with 2 parameters called." << endl;
}
void display() {
cout << "ID: " << id << ", Name: " << name << endl;
}
};
int main() {
Student s1;
Student s2(101);
Student s3(025, "Kruthika");
cout << endl << "Student Info:" << endl;
s1.display();
s2.display();
s3.display();
return 0;
}