-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathq11.cpp
35 lines (28 loc) · 800 Bytes
/
q11.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
#include <iostream>
#include <string>
using namespace std;
template <typename T>
class Student {
private:
T name;
int age;
T course;
T department;
public:
Student(T n, int a, T c, T d) : name(n), age(a), course(c), department(d) {}
void displayData() {
cout << "Name: " << name << endl;
cout << "Age: " << age << endl;
cout << "Course: " << course << endl;
cout << "Department: " << department << endl;
}
};
int main() {
Student<string> student1("Alice", 20, "Computer Science", "Engineering");
Student<string> student2("Bob", 22, "Mechanical Engineering", "Engineering");
cout << "Student 1 Data:" << endl;
student1.displayData();
cout << "\nStudent 2 Data:" << endl;
student2.displayData();
return 0;
}