+ 1
What is a .* operator in C++, and why can it not be overloaded?
Operator overloading section of the C++ course in sololearn says that .* operator cannot be overloaded. What is a .* operator and what does it do? What is the reason behind not allowing to overload it?
2 Respostas
+ 3
I've coded in C++ for decades and never used this operator before in my life. This is what you can do with it.
https://code.sololearn.com/cTfydBS0k7J5
Why you would want to? I don't know. Everything I tried with b, I could do with a so I haven't found a reason for it. However, it makes sense to prevent it's overloading as it can only be used in this exact scenerio so there really is no way to change it's behavor for the class.
+ 2
I found a reason in John McFarlane's answer here:
https://stackoverflow.com/questions/670734
He passed which integer property to sum to a function so, instead of having two different functions, he could do it with one.