0

Need of overloaded & operator

Why would one overload & operator? Refer class Test1 and we have made address of private member available to user. Isn't this dangerous situation and violates OOPS? I am more curious to know its elegant usage to have idea of importance of & operator overloaded https://sololearn.com/compiler-playground/c9P4sUwRNLgP/?ref=app

18th Dec 2024, 11:33 AM
Ketan Lalcheta
Ketan Lalcheta - avatar
2 Respuestas
+ 1
It is dangerous I've never seen any logical instance to overload it except if you want to manipulate or give custom addresses ofc
18th Dec 2024, 6:18 PM
RuntimeTerror
RuntimeTerror - avatar
0
True. C++ allow many things which are dangerous and should not be done intentionally However, just concerned why it has been provided. Definitely some good scenario it is handling and curious to know what is that
19th Dec 2024, 2:46 AM
Ketan Lalcheta
Ketan Lalcheta - avatar