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 a C++ quote?

2025-04-09 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

This article mainly introduces "what is C++ citation". In daily operation, I believe many people have doubts about what is C++ citation. The editor consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful to answer the questions of "what is C++ citation"! Next, please follow the editor to study!

I. quotation from C++

The variable name itself is a reference to a piece of memory, that is, an alias (alias). The reference introduced here is an alias for your own variable.

The statement is as follows

Int main () {int a; int & b = a;} 1. Rules

1. A reference is undefined and is a relational declaration. Declare its relationship with an original variable. The type is consistent with the original type, and no memory is allocated. Has the same address as the referenced variable.

two。 The declaration must be initialized, and once declared, it cannot be changed.

3. Can be referenced again. The result of multiple references is that a variable has multiple aliases.

4.When the symbol is preceded by a data type, it is a reference. The others are taken from the address.

# include using namespace std;int main () {int adirection b; int & r = a; int & r = b; / / error. The original reference relationship float & rr = b; / / cannot be changed. The reference type does not match cout.

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: 217

*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

Development

Wechat

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

12
Report