Get the App
SLTechnology News&Howtos  ›  Development  › 

Example Analysis of C++ operator

Shulou Source: shulou.com Published: 2022-06-02 22:38:50 10月03日 Update

This article introduces you the example analysis of C++ operator, the content is very detailed, interested friends can refer to, hope to be helpful to you.

C++ operator is an advanced C++ technology in C++, the following introduction, you may find that some operators use the same symbols, the meaning of symbols can change with the environment, you can learn through the program and code to understand its important issues.

There are many operators in C++. I don't want to list them all here, but only the most commonly used operators, as shown in the following table. Examples of commonly used C++ operators:

The arithmetical operator + plus x quoz;-minus x quoz; * multiplicates x quoz; / divides x quoz; assignment operator = assignment x times 10; + = assignment and and x times 10; (equal to xx=x+10;)-= assignment and subtraction x words 10; * = assignment and division x\ = 10; & = assignment bits and x parts 0x02; | = assignment bits or x | = 0x02 Logic operator & & Logic and if (x & & 0xFF) {...} | Logic or if (x | | 0xFF) {...} equation operator = = equal to if (x = = 10) {...}! = not equal to if (x! = 10) {...}

< 小于 if(x < 10) {...} >

Greater than if (x > 10) {...} = 10) {...} unary operator * indirect operator int x operators; & address operator int* x operators; ~ bit non-x & = ~ 0x02;! Logical non-if (! valid) {...} + increment operator Xray + (equal to xx=x+1;)-- decrement operator XMurray; class and structure operators:: range resolution MyClass:: SomeFunction ();-> indirect member MyClass- > SomeFunction (); direct member MyClass. SomeFunction ()

As you can see, this list is too long to remember at once. You will gradually become familiar with these operators when using C++. It is important to note that the increment C++ operator can be used either as a pre-increment (+ + x) or as a post-increment (x increment +). The pre-increment operator tells the compiler to increment before using the variable, and then the increment C++ operator tells the compiler to use the value of the variable before incrementing. For example, the following code:

Int x = 10; cout

Tags: Operators caching logic content overload examples analysis code variables commonly used members more symbols compilers operators Augu help compilation operations good Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno macOS Huawei MySQL OPPO Reno Xiaomi