As per the comment under this answer, references were introduced primarily to support operator overloading which quotes Bjarne Stroustrup:
References
Why doesn't it work for pointers? Because it's ambiguous. Would
ostream* operator<<(ostream* s, const char* c);
match
cout << 'a';
or
cout << "a";
?
Also, you can't use address-of (&
) with a temporary. What should this do:
complex a, b, c;
cout << a + b * c;
since b * c
is a temporary, and the sum is also.
?