-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpractice15.cpp
More file actions
41 lines (34 loc) · 739 Bytes
/
practice15.cpp
File metadata and controls
41 lines (34 loc) · 739 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
#include <iostream>
using namespace std;
class Employee
{
public:
Employee(string, int);
string nickname;
private:
string name;
int salary;
friend void print(Employee);
};
Employee::Employee(string name, int salary)
{
this->name = name;
this->salary = salary;
}
void print(Employee employee)
{
cout << "Name: " << employee.name << endl;
cout << "Salary: " << employee.salary << endl;
}
// Member variables are inaccessible for "non-friend" functions.
// void printDetails(Employee employee)
// {
// cout << "Name: " << employee.name << endl;
// cout << "Salary: " << employee.salary << endl;
// }
int main()
{
Employee employee("Aryan", 99999999);
print(employee);
return 1;
}