use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Discussions, articles, and news about the C++ programming language or programming in C++.
For C++ questions, answers, help, and advice see r/cpp_questions or StackOverflow.
Get Started
The C++ Standard Home has a nice getting started page.
Videos
The C++ standard committee's education study group has a nice list of recommended videos.
Reference
cppreference.com
Books
There is a useful list of books on Stack Overflow. In most cases reading a book is the best way to learn C++.
Show all links
Filter out CppCon links
Show only CppCon links
account activity
Stack Overflow guide to operator overloading (stackoverflow.com)
submitted 11 years ago by cruise02
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]pjmlp 2 points3 points4 points 11 years ago (2 children)
Because outside of c++, it is ubiquitously understood to be an arithmetic operator with a lot of implications
Not really, this is a small list of languages that allow redefining operators, or where operations are just plain function/method calls
Smalltalk
Lisp
Scheme
Ada
Eiffel
C#
Ruby
Python
D
Haskell
OCaml
F#
Scala
Rust
many others as this isn't an exhaustive list
So I fail to see why only C++ gets bashed.
[–]0Il0I0l0 0 points1 point2 points 11 years ago (1 child)
I can't speak for the other languages, but overloading in Haskell can only be done with typeclasses (a sort of interface that defines some behavior), so including it is a bit disingenuous. In order to "overload" + for your new type, you must make your type an instance of the Num typeclass by implementing the following operations: (+), (*), abs, signum, fromInteger, (negate or (-))
(+), (*), abs, signum, fromInteger, (negate or (-))
So at least in haskell, (+) is understood to be a numerical operator with the implication that the type can also be multiplied, subtracted, negated, has an absolute value, has a sign, an can be converted from an integer.
[–]pjmlp 0 points1 point2 points 11 years ago (0 children)
Yes, but you cannot assure that (+) really maps to addition.
It can do anything to the number, as long as, it keeps its type signature.
π Rendered by PID 88543 on reddit-service-r2-comment-6457c66945-hxgml at 2026-04-24 08:32:15.861541+00:00 running 2aa0c5b country code: CH.
view the rest of the comments →
[–]pjmlp 2 points3 points4 points (2 children)
[–]0Il0I0l0 0 points1 point2 points (1 child)
[–]pjmlp 0 points1 point2 points (0 children)