File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ #include < iostream>
2+ #include < string>
3+ using namespace std ;
4+
5+ class Student {
6+ private:
7+ int id;
8+ string name;
9+ double grade;
10+
11+ public:
12+ // Constructor
13+ Student (int id, string name, double grade) {
14+ this ->id = id;
15+ this ->name = name;
16+ this ->grade = grade;
17+ }
18+
19+ // Getters
20+ int getId () { return id; }
21+ string getName () { return name; }
22+ double getGrade () { return grade; }
23+
24+ // Setters
25+ void setId (int id) { this ->id = id; }
26+ void setName (string name) { this ->name = name; }
27+ void setGrade (double grade) { this ->grade = grade; }
28+
29+ // Display
30+ void display () {
31+ cout << " ID: " << id << " , Name: " << name << " , Grade: " << grade << endl;
32+ }
33+ };
34+
35+ // Example usage
36+ int main () {
37+ Student s1 (1 , " Alice" , 95.5 );
38+ s1.display ();
39+ return 0 ;
40+ }
You can’t perform that action at this time.
0 commit comments