Home > Backend Development > C++ > body text

What are the c++ operators?

下次还敢
Release: 2024-04-22 17:30:33
Original
694 people have browsed it

C provides an extensive set of operators, classified as follows: Arithmetic operators ( , -, *, /, %, , --) Assignment operators ( =, =, -=, *=, /= , %=) comparison operators (==, !=, <, >, <=, >=) logical operators (&, |, ^,!) bitwise operators (&, |, ^, <<, >>) Pointer operators (*, &, ->) Other operators (sizeof, ?:,,,)

What are the c++ operators?

C Operator Overview

C is a powerful programming language with a rich set of operators for performing a variety of operations. These operators can be divided into the following categories:

1. Arithmetic operators

  • , -, *, /, %: basic arithmetic operators, Used for addition, subtraction, multiplication, division and modulo respectively.
  • , --: auto-increment and auto-decrement operators, increase or decrease the variable value by 1 respectively.

2. Assignment operator

  • =: The basic assignment operator assigns the value of the right operand to the left operand.
  • =, -=, *=, /=, %=: compound assignment operator, which performs arithmetic operations and assignment at the same time.

3. Comparison operators

  • ==, !=: equality and inequality operators.
  • <, >, <=, >=: comparison operators.

4. Logical operators

  • &, |, ^: AND, OR, XOR operators.
  • !: Not operator, inverts the Boolean value of the operand.

5. Bitwise operators

  • &, |, ^: bitwise AND, bitwise OR, bitwise XOR operators.
  • <<, >>: Bitwise left shift and bitwise right shift operators.

6. Pointer operator

  • *: Value operator, returns the value pointed by the pointer.
  • &: Take the address operator and return the address of the variable.
  • ->: Member access operator, used to access members of a structure or class.

7. Other operators

  • sizeof: Returns the byte size of the data type.
  • ?:: Conditional operator, returns different values ​​based on conditional expressions.
  • ,: Comma operator, executes expressions sequentially.

The above is the detailed content of What are the c++ operators?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
c++
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template