Home > Backend Development > C++ > What symbols are used in c++?

What symbols are used in c++?

下次还敢
Release: 2024-05-01 10:36:14
Original
761 people have browsed it

The assignment operator (=) in C is used to copy a value to another variable. In addition, C provides other assignment operators for combining assignment operations, such as = (additive assignment), -= (subtractive assignment), and *= (multiplicative assignment).

What symbols are used in c++?

Assignment in c

In C, the assignment operator is used to copy the value of one variable to another in a variable. The assignment operator is =.

Basic syntax

<code class="cpp">变量 = 值;</code>
Copy after login

For example:

<code class="cpp">int x = 10;</code>
Copy after login

This will change the variablex## The value of # is set to 10.

Assigned to the reference

If the variable is a reference, the assignment operator will modify the referenced target variable value. For example:

<code class="cpp">int& y = x;
y = 20;</code>
Copy after login
This changes the value of variable

x to 20.

Other assignment operators

In addition to the basic assignment operators, C also has several other assignment operators for combined assignment operations:

  • = (Additional assignment)
  • -= (subtraction assignment)
  • *= (multiplication assignment)
  • /= (division assignment)
  • %= (modulo assignment)
  • <<= (left shift assignment)
  • > ;>= (right shift assignment)
  • &= (bitwise AND assignment)
  • |= (bitwise OR Assignment)
  • ^= (Bitwise XOR assignment)
For example:

<code class="cpp">x += 5; // 等同于 x = x + 5</code>
Copy after login

The above is the detailed content of What symbols are used in c++?. 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