On 10/28/10 05:18 PM, Ian Collins wrote:
> On 10/28/10 05:10 PM, cronusf wrote:
>>
>> std:
stream& operator<<(std:
stream& os, Complex& c)
>> {
>> os<< "("<< c.real<< ", "<< c.imag<< ")"<< std::endl;
>>
>> return os;
>> }
>>
>> int main()
>> {
>> Complex c1(1.0f, 2.0f);
>> Complex c2(1.0f, 2.0f);
>>
>> std::cout<< c1 + c2<< std::endl;
>> }
>>
>> Output: (2, 4)
>
> That shouldn't compile. There isn't a suitable operator << for Complex.
Which probably means that compiler doesn't enforce the can't bind a
temporary to a non const reference rule. So what you see is compiler,
rather than language specific.
--
Ian Collins