Get the App
SLTechnology News&Howtos  ›  Development  › 

An example Analysis of C++ operator

Shulou Source: shulou.com Published: 2022-06-02 09:42:27 09月22日 Update

This article mainly explains "C++ operator example Analysis", interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Now let the editor to take you to learn the "C++ operator example analysis" bar!

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. When using the C++ operators, you will gradually become familiar with these operators. It is important to note that the increment operator can be used as either pre-increment (+ + x) or post-increment (xincrement +). The pre-increment operator tells the compiler to increment before using the variable, and then the increment operator tells the compiler to use the value of the variable before incrementing. For example, the following code:

Int x = 10; cout

Tags: Operators cantilever logic overload analysis content differences variables members pointers symbols compilers operators Augu learning compilation operations deeper same advanced Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Tech Info Xiaomi vpn Shulou Technology Docker