Some records for C + + operator overloading

Source: Internet
Author: User


1. Which can not be overloaded?

. .*

2. Does the member function differ from the operator overloading function of a non-member function?
Whether the left side of the operator is the class object itself.

3. a++, ++a operation
X operator + + (const x& X);
Const x& operator + + (const x& X, int);
The int parameter exists as a dummy element because the identifier is post-added, because x + + cannot be left-valued so the return value is const x&

4. Use implicit conversions as little as possible
Include conversion of constructors to join explicit
Overloaded operator operator ()

5.<c++ Strategies & tactics> Description
All unary operators recommend the use of Members
= () []->* must use members
+ = = *=/= ^= &= |=%= >>= <<= recommended use of Members
All other two-tuple operators recommend the use of non-member

Some records for C + + operator overloading

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.