aboutsummaryrefslogtreecommitdiff
path: root/C++.wiki
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@hornquist.se>2019-12-24 01:13:50 +0100
committerHugo Hörnquist <hugo@hornquist.se>2019-12-24 01:13:50 +0100
commit9d5b7989268146f56f7a1d68f7e528e557fc921a (patch)
tree982c7d4e9506f666680cae3e2ca51e46cf3f0b2b /C++.wiki
parentWed, 11 Dec 2019 16:37:15 +0100 (diff)
downloadwiki-public-9d5b7989268146f56f7a1d68f7e528e557fc921a.tar.gz
wiki-public-9d5b7989268146f56f7a1d68f7e528e557fc921a.tar.xz
Tue, 24 Dec 2019 01:13:50 +0100
Diffstat (limited to 'C++.wiki')
-rw-r--r--C++.wiki36
1 files changed, 36 insertions, 0 deletions
diff --git a/C++.wiki b/C++.wiki
new file mode 100644
index 0000000..b3dec5e
--- /dev/null
+++ b/C++.wiki
@@ -0,0 +1,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;
+}
+}}}