Start here · Essential guide
Assignment Operators in C++
Learn about C++ assignment operators: the = operator, compound forms like += and -=, chaining, and common mistakes, with short code examples.
Syntax and Functions
Plain and compound assignment, plus the address and dereference operators.
Start here · Essential guide
Learn about C++ assignment operators: the = operator, compound forms like += and -=, chaining, and common mistakes, with short code examples.
The ++i and i++ operators both add one to a variable, but ++i uses the new value and i++ uses the old one. Examples show the difference in C.
The & operator gets the address of a variable and the * operator reads or changes the value at an address. Here is how both work, with code examples.
The assignment operator is the equals sign, =. It stores the value on its right in the variable on its left, as this short example clearly shows.
The operator for assignment in C is the single equals sign, =. Here is how it compares with ==, +=, and other symbols that are easy to mix up.
Related topics