By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,750 Members | 1,159 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,750 IT Pros & Developers. It's quick & easy.

operator +

P: n/a
Dear all,

I am wondering where the operator + should be defined. In the global
domain, or the class domain.

For example

class A
{
A operator + (const A& second) const;
}

or

A operator + (const A& first, const A& second);

And are they the same?

Thanks,

Shuisheng

Sep 26 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a

shuisheng wrote:
I am wondering where the operator + should be defined. In the global
domain, or the class domain.

For example

class A
{
A operator + (const A& second) const;
}

or

A operator + (const A& first, const A& second);

And are they the same?
Hello,

The latter possibility may be better. The difference is that
if you had type B implicitly convertible to A, the second definition
would do for B+A, but the first no.

Jiri Palecek

Sep 26 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.