blob: b3dec5ea1f1687bcb0b2561e69e6ca33a2b8aa02 (
plain)
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
|
= Contents =
- [[#C++ Examples|C++ Examples]]
- [[#C++ Examples#Friend operator|Friend operator]]
= C++ Examples =
== Friend operator ==
{{{c++
#include <iostream>
class T {
int x;
public:
T (int x);
friend std::ostream& operator<<(std::ostream&, const T&);
};
T::T (int x) {
this->x = x;
}
std::ostream& operator<<(std::ostream& out, const T& t) {
out << "T {" << t.x << "}";
return out;
}
int main () {
T t(10);
std::cout << t << std::endl;
}
}}}
|