If I overload an operator, such as <<, what will be the associativity?
For my tests I used a simple class, defined as:
class Complex {
Complex(float re = 0, float im = 0) {
real = re;
imag = im;
}
const Complex & operator=(const Complex& c) {
if (this != &c) {
real = c.real;
imag = c.imag;
}
return *this;
}
ostream& operator << (ostream& out, const Complex& z) {
z.show(out);
return out;
...
}
};
My tests have shown that operator<<(ostream& out, const Complex& z) is left-to-right associative, as is usual for the << operator. Also, operator=(const Complex &c) is right-to-left associative, as is normal for the = operator.
This leads me to believe that the associativity of my overloaded operators is based on the associativity of the default operators (or that the actual symbols used specify associativity, and not the function itself). My lecturer however, tells me that the associativity is decided by the compiler based on the return types of the overloaded operators.
Which is correct?
(or, if I've explained it poorly, just answer: How is the associativity for overloaded operators determined?)
yeah it seems to be Edge only. The dialog buttons work as expected in Chrome and Firefox. The phone is using Android 16 (OneUI 8.5) and Edge version 149.0.4022.53
I'm not aware of this issue, but to help the other guys.
What version of Android are you using?
Did you try a different browser? To see if Edge is the issue here.
I agree when are you going to read this (really poor BTW) article?
Here is a better article so you actually know what is going on and answers questions you had in other comments --> https://arstechnica.com/gadgets/2026/05/speed-boosting-low-latency-profile-is-one-of-the-improvements-coming-to-windows-11/
It is unclear if one will be able to disable the new profile at this point but I am not seeing any reason why one would.
I disagree; they come off very "bitchy" and "whiny".
Make a great product and combine that with a great price (free) and people will come over to your side. Or build it and they will come as they say.
Constantly trying to get attention by complaining all the time, will turn people off to your product.
Question
Bukkfrig
If I overload an operator, such as <<, what will be the associativity?
For my tests I used a simple class, defined as:
class Complex { Complex(float re = 0, float im = 0) { real = re; imag = im; } const Complex & operator=(const Complex& c) { if (this != &c) { real = c.real; imag = c.imag; } return *this; } ostream& operator << (ostream& out, const Complex& z) { z.show(out); return out; ... } };My tests have shown that operator<<(ostream& out, const Complex& z) is left-to-right associative, as is usual for the << operator. Also, operator=(const Complex &c) is right-to-left associative, as is normal for the = operator.
This leads me to believe that the associativity of my overloaded operators is based on the associativity of the default operators (or that the actual symbols used specify associativity, and not the function itself). My lecturer however, tells me that the associativity is decided by the compiler based on the return types of the overloaded operators.
Which is correct?
(or, if I've explained it poorly, just answer: How is the associativity for overloaded operators determined?)
Thanks for your help.
Link to comment
https://www.neowin.net/forum/topic/447385-c-overloaded-operator-associativity/Share on other sites
3 answers to this question
Recommended Posts