Category "operators"

Why does JavaScript handle the plus and minus operators between strings and numbers differently?

I don't understand why JavaScript works this way. console.log("1" + 1); console.log("1" - 1); The first line prints 11, and the second prints 0. Why does Jav

Simplifying code - perform mathematical operations based on operator

Here is the code for a calculator in Python: import time #Returns the sum of num1 and num2 def add(num1, num2): return num1 + num2 #Returns the difference

How to overload == operator? [closed]

I'm using QT to design an app and I can't overload == for a class. Equals works perfectly but == doesn't work and I can't figure out why. Her

How to use an operator from a specific base class on multiple inheritance context on C++

I'm writing some C++ codes, and I can't compile the following code on g++. It only says that std::string hasn't a method named "operator==". I know it's not tru

Asterisk in function call [duplicate]

I'm using itertools.chain to "flatten" a list of lists in this fashion: uniqueCrossTabs = list(itertools.chain(*uniqueCrossTabs)) how is th

How to implement C++ (in)equality operators for aggregate structs?

Sometimes I have structs such as this -- struct aggregate1 { std::string name; std::vector<ValueT> options; size_t foobar; // ... }; -- where (

What are the basic rules and idioms for operator overloading?

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