File tree Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change 94
94
\end {block }
95
95
\end {frame }
96
96
97
+ \begin {frame }[fragile]
98
+ \frametitlecpp [98]{Chaining operators}
99
+ \begin {block }{In general, return a reference to the left value}
100
+ \begin {cppcode }
101
+ struct Complex {
102
+ float m_real, m_imaginary;
103
+ Complex& operator=( const Complex& other ) {
104
+ m_real = other.m_real;
105
+ m_imaginary = other.m_imaginary;
106
+ return *this;
107
+ }
108
+ };
109
+ Complex c1{2.f, 3.f};
110
+ Complex c2, c3;
111
+ // right to left associativity
112
+ c3 = c2 = c1;
113
+ // left to right associativity
114
+ std::cout << c1 << c2 << c3 << std::endl;
115
+ \end {cppcode }
116
+ \end {block }
117
+ \end {frame }
118
+
97
119
\begin {frame }[fragile]
98
120
\frametitlecpp [98]{Friend declarations}
99
121
\begin {block }{Concept}
You can’t perform that action at this time.
0 commit comments