Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

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

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

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!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report