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 are the references passed in C++?

2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

This article mainly explains "what are the citation transmission in C++". The content of the explanation in the article is simple and clear, and it is easy to learn and understand. Now please follow the editor's train of thought slowly and deeply. Let's study and learn what are the citation transmission in C++!

Citation delivery in C++

In C++, parameter passing includes value passing, and its usage is the same as in C language, but reference passing, as a major feature of C++, is not supported in C language.

1. Creation of reference variables: int rats;// creates reference variables rodents as aliases for rats int & rodents = rats; considerations for using reference variables:

Initialize when declared

Once associated with a variable, allegiance is only to that variable

For the first article above:

The disallowed use of int rats;// int & rodents;rodents = rats

For the second article, you can refer to the following example:

# include

< iostream >

Using namespace std;int main (void) {int rats = 10; int & rodents = rats; int bunnies = 20; 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: 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

Development

Wechat

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

12
Report