Skip to content

Commit 5afa999

Browse files
authoredAug 24, 2022
Add files via upload
1 parent 3d2dc6a commit 5afa999

File tree

59 files changed

+1381
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+1381
-0
lines changed
 

‎Friend/Friend function/add.cpp

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#include<iostream>
2+
#include<stdio.h>
3+
using namespace std;
4+
class calculation{
5+
//wap for friend function
6+
int a;
7+
int b;
8+
private:
9+
int sum=0;
10+
public:
11+
void set(int c,int d){
12+
a=c; b=d;}
13+
friend void add(calculation c);
14+
friend void sub(calculation c);
15+
};
16+
void add(calculation c1){ int sum=c1.a+c1.b; cout<<"Friend function 1 called \n"; cout<<"Sum is:"<<sum<<endl; }
17+
void sub(calculation c1){ int sub=c1.a-c1.b; cout<<"Friend function 2 called \n"; cout<<"Sub is:"<<sub<<endl; }
18+
int main(){
19+
int x,y;
20+
cout<<"Enter first number:";
21+
cin>>x;
22+
cout<<"Enter second number:";
23+
cin>>y;
24+
calculation c;
25+
c.set(x,y);
26+
add(c);
27+
sub(c);
28+
return 0;
29+
}
30+

‎Friend/Friend function/add.exe

44.8 KB
Binary file not shown.

0 commit comments

Comments
 (0)
Please sign in to comment.