Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 2b49fce

Browse files
Friend functions
1 parent 8b55652 commit 2b49fce

File tree

1 file changed

+34
-0
lines changed
  • Learn_CPP_Programming_Deep_Dive/Section 16 Friend and static members/Friend_functions

1 file changed

+34
-0
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#include <iostream>
2+
3+
using namespace std;
4+
5+
class Test
6+
{
7+
private:
8+
int a;
9+
protected:
10+
int b;
11+
public:
12+
int c;
13+
14+
friend void myfunction();
15+
16+
};
17+
18+
19+
void myfunction()
20+
{
21+
Test t;
22+
t.a = 12;
23+
t.b = 45;
24+
t.c =46;
25+
26+
cout<<"This is from inside myfunction()"<<endl;
27+
}
28+
29+
int main(void)
30+
{
31+
myfunction();
32+
33+
return 0;
34+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /