Home What are the basic rules and idioms for operator overloading?
Reply: 0

What are the basic rules and idioms for operator overloading?

user8364
1#
user8364 Published in September 19, 2018, 7:09 pm

Note: The answers were given in a specific order, but since many users sort answers according to votes, rather than the time they were given, here's an index of the answers in the order in which they make most sense:

  • The General Syntax of operator overloading in C++
  • The Three Basic Rules of Operator Overloading in C++
  • The Decision between Member and Non-member
  • Common operators to overload
    • Assignment Operator
    • Input and Output Operators
    • Function call operator
    • Comparison operators
    • Arithmetic Operators
    • Array Subscripting
    • Operators for Pointer-like Types
    • Conversion Operators
  • Overloading new and delete

(Note: This is meant to be an entry to Stack Overflow's C++ FAQ. If you want to critique the idea of providing an FAQ in this form, then the posting on meta that started all this would be the place to do that. Answers to that question are monitored in the C++ chatroom, where the FAQ idea started out in the first place, so your answer is very likely to get read by those who came up with the idea.)

share|improve this question
  • 56
    If we're going to continue with the C++-FAQ tag, this is how entries should be formatted. – John Dibling Dec 14 '10 at 19:45
  • I've written a short series of articles for the german C++ community about operator overloading: Part 1: operator overloading in C++ covers semantics, typical usage and specialities for all operators. It has some overlappings with your answers here, nevertheless there is some additional information. Parts 2 and 3 make an tutorial for using Boost.Operators. Would you like me to translate them and add them as answers? – Arne Mertz Apr 9 '13 at 14:11
  • Oh, and an English translation is also available: the basics and common practice – Arne Mertz Jul 31 '17 at 14:13

7 Answers 7

active oldest votes
up vote 445 down vote
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.394115 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO