Overloading in c++ | Sololearn: Learn to code for FREE!
+ 1

Overloading in c++

Why we can't overload '=' by using frnd fn?

5th Feb 2022, 3:57 PM
Brat__ - avatar
1 Respuesta
+ 5
It is because assignment operator is one of the "special member operator" in C++ ( special member functions are the functions which are generated by compiler if it doesn't find one at the time of its use ) If you attempt to overload it via friend function, then your definition would conflict with compiler generated definition causing ambiguity ( resulting in compilation error )
5th Feb 2022, 5:08 PM
Arsenic - avatar