-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUntitled1.cpp
More file actions
38 lines (32 loc) · 877 Bytes
/
Untitled1.cpp
File metadata and controls
38 lines (32 loc) · 877 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
#include<iostream>
using namespace std;
class name{
int tax;
int selery;
public:
name(int tax,int selery){
this->tax = tax;
this->selery = selery;
}
friend int cal_sum(name aa);
};
int cal_sum(name aa){
cout<<aa.tax*aa.selery;
}
int main(){
name aa(9,7);
cal_sum(aa); // can't call it by usign obj name b/c its not member function .
return 0;
}
/*
Now let see class name is (name) object is (aa)
first we make constructore assigne values to private
member.and then declear friend function not define .
use keyword (friend)then use (data_type)and then
(function name)and then pass the class name and obj
is a argument.
now defin such friend function outside class just like
simple function b/c its not member function.
now in main function call just like simple function
b/c its not member function.
*/