-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpractice8.cpp
51 lines (42 loc) · 970 Bytes
/
practice8.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
48
49
50
51
#include <iostream>
#include <memory>
#include <string>
using namespace std;
struct Student
{
string fName;
string lName;
int age;
int roll;
// Student partner; // Not allowed; Think about this-> You'd end up with a case of infinite recursion.
Student *partner;
};
string getFullName(Student *student)
{
return student->fName + " " + student->lName;
}
void preview(Student student)
{
cout << "Full name: " << getFullName(&student) << endl;
cout << "Age: " << student.age << endl;
cout << "Roll: " << student.roll << endl;
cout << "Project partner: " << getFullName(student.partner) << endl;
}
int main()
{
Student s1, s2;
s1.age = 12;
s1.fName = "Aryan";
s1.lName = "Jain";
s1.roll = 435876;
s1.partner = &s2;
s2.age = 11;
s2.fName = "John";
s2.lName = "Williams";
s2.roll = s1.roll + 1;
s2.partner = &s1;
preview(s1);
cout << endl;
preview(s2);
return 1;
}