+ 1
The Example In Lesson
" class MyClass { public: int var; MyClass() {} MyClass(int a) : var(a) { } MyClass operator+(MyClass &obj) { MyClass res; res.var= this->var+obj.var; return res; } }; " in this example, why do we need '&' ?
2 Réponses
+ 1
it is pass by reference. we do not need it for a simple operation like thst tho, but that may be just faster to do it that way (for PC, not for you).
http://www.learncpp.com/cpp-tutorial/73-passing-arguments-by-reference/
0
thanks!