Operators and Punctuators
Operators and Punctuators
Arithmetic, comparison, logical, bitwise, access, cast, and punctuation tokens across C and C++.
Operators and Punctuators
Arithmetic, comparison, logical, bitwise, access, cast, and punctuation tokens across C and C++.
Use reference pages to confirm names, categories, nearby facilities, and the constraints that matter before writing or reviewing code.
+, unary -+, -, *, /, %++, --==, !=, <, <=, >, >=<=>!&&||not, and, or~&, |, ^<<, >>&=, |=, ^=, <<=, >>=bitand, bitor, xor, compl, and_eq, or_eq, xor_eq=+=, -=, *=, /=, %=. member access-> pointer member access[] subscript() function call:: scope resolution in C++.* and ->* pointer-to-member access in C++&*(type)static_cast, dynamic_cast, const_cast, reinterpret_castsizeof, alignof, decltype, typeid, noexcept?:,...;,:{ }( )[ ]< >C++ allows many operators to be overloaded, including:
() and []-> in special proxy designsNot overloadable include:
..*::?:sizeoftypeidstruct Point {
int x{};
int y{};
};
int main() {
Point p{3, 4};
int sum = p.x + p.y;
bool large = sum >= 7 && p.x != 0;
return large ? sum : 0;
}
This one short program touches member access ., arithmetic +, comparison >=, logical &&, inequality !=, assignment =, and the conditional operator ?:. That is a better operator reference example than a generic loop because the operators themselves are the point.
#include <iostream>
struct Point {
int x{};
int y{};
};
int main() {
Point p{3, 4};
int total = (p.x + p.y) * 2;
bool large = total >= 10 && p.x != 0;
std::cout << (large ? total : 0) << '\n';
}