-
Notifications
You must be signed in to change notification settings - Fork 0
/
day7.cpp
47 lines (37 loc) · 926 Bytes
/
day7.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
#include <iostream>
using namespace std;
class FriendClass;
class Student {
private:
string name;
int rollNumber;
public:
Student(string n, int rn) {
name = n;
rollNumber = rn;
}
string getName() const {
return name;
}
int getRollNumber() const {
return rollNumber;
}
friend void displayStudentDetails(Student s, FriendClass f);
};
class FriendClass {
public:
void displayFriendMessage(Student s) {
cout << "Hello, " << s.getName() << "! Your roll number is " << s.getRollNumber() << endl;
}
};
void displayStudentDetails(Student s, FriendClass f) {
cout << "Student Name: " << s.getName() << endl;
cout << "Roll Number: " << s.getRollNumber() << endl;
f.displayFriendMessage(s);
}
int main() {
Student student("Alice", 123);
FriendClass friendObj;
displayStudentDetails(student, friendObj);
return 0;
}