operator overloading

O

osmium

Ben Pope said:
I don't know. Perhaps you don't know how.

What have you tried?

Well, Eckel, for one, says it can't be a friend. ISTM this question
belongs on comp.std.c++ but there are a ton of language lawyers that hang
around here so I suppose you will get an answer.
 
J

Jerry Coffin

@u72g2000cwu.googlegroups.com>, (e-mail address removed)
says...
Why we can't overload = operator using friend function?

Because it doesn't really make sense. For most operators,
you use a friend function to allow the left operand to be
converted from some other type before the operator is
applied. Since the temporary object is automatically
const qualified, you can't assign to it. Even if you
could, you'd be assigning a new value to a temporary
that's just going to be discarded at the end of that
statement anyway...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,280
Latest member
BGBBrock56

Latest Threads

Top