0

operator & overloading

Hi as we can't overload few operator, address of is not one of them. I am wondering why we need to overload this operator? Isn't it give memory address? Is such operation in our control?

7th Jun 2020, 12:32 PM
Ketan Lalcheta
Ketan Lalcheta - avatar
3 Respostas
+ 1
Owing to the lack of an answer for the past few days,I think its safe to assume that overloading it would be of no use. I thought that smart pointers such as unique_ptr and shared_ptr might have overloaded it but it turns out even such classes use compiler generated versions of the operator&() function. So I think coming up with your our own user defined function is not useful nor recommend at all.
11th Jun 2020, 12:21 PM
Anthony Maina
Anthony Maina - avatar
+ 1
Anthony Maina I had found an answer of this on below link : https://stackoverflow.com/questions/6499502/why-would-anyone-want-to-overload-the-address-of-operator/6499540#6499540 It looks good and once I am convinced... But at the same time thinking out of box , I feel that why to have this overloaded operator... Stil I am thinking on this and wanna do some dummy code of what has been told in accepted answer by this weekend (probably)
11th Jun 2020, 4:15 PM
Ketan Lalcheta
Ketan Lalcheta - avatar
+ 1
Oh okay....I learned something new today
11th Jun 2020, 4:18 PM
Anthony Maina
Anthony Maina - avatar