Skip to content

Commit b28e9ec

Browse files
committed
Friend Function revision
1 parent 253ab20 commit b28e9ec

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#include<iostream>
2+
3+
class Demo {
4+
5+
int x;
6+
public:
7+
Demo(int x) {
8+
9+
this->x = x;
10+
}
11+
12+
friend void fun(const Demo& obj);
13+
};
14+
15+
void fun(const Demo& obj) {
16+
17+
std::cout << obj.x << std::endl;
18+
}
19+
20+
int main() {
21+
22+
Demo obj(10);
23+
fun(obj);
24+
}

0 commit comments

Comments
 (0)