Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

What is the reference method for the right value of Category 11?

Shulou Source: shulou.com Published: 2022-06-01 19:48:40 10月04日 Update

This article introduces the knowledge of "what is the right value citation method of Category 11". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

Left and right valu

There is a concept of left and right values in the properties of C++ expressions. If an expression can be placed on the left side of the assignment statement, it is called the left value, and if it cannot be placed on the left side of the expression, it is called the right value.

Different operators have different requirements for operands, such as:

The left side of the assignment operator requires a left value, and the result is still a left value, so we can continue to assign it

The address character is used for the left-value Operand, and the pointer of the returned object is the right value, so the address operation expression can only be located on the right side of the assignment statement.

Right value reference

Clocking 11 introduces a reference that must be bound to the right value: the right value reference. To distinguish it from normal reference types, Category 11 uses & & to declare right-value references. For example:

Int & & cr = 5; / / 5 is the right value, bind OK!

To deepen your understanding, look at the general reference types:

Int I = 0

Int & r = I; / / OK!

No problem, I is the left value, so you can bind the r of the reference type to I, and the future operation on r is the same as the operation on I.

However, if you bind the application to the right value, or bind the right value reference to the left value, it will cause an error, like the following code:

Int I = 0

Int & & rr = I; / / error!, I is the left value

Int & r = I * 42; / / error! I * 42 is the right value.

This is the end of the content of "what is the method of clocking 11 right value reference". Thank you for your reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Tags: Operations expressions objects types errors methods contents addresses more knowledge statements operators different practical same learned next code function right Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno vpn Microsoft OPPO Reno Shulou Information NVidia