Get the App
SLTechnology News&Howtos  ›  Development  › 

Citation methods in C++

Shulou Source: shulou.com Published: 2022-05-31 21:54:42 09月30日 Update

The editor of this article introduces "the citation method in C++" in detail, the content is detailed, the steps are clear, and the details are handled properly. I hope this "citation method in C++" article can help you solve your doubts. Let's go deeper and deeper with the editor's train of thought. Let's learn new knowledge.

Background

In cUniverse +, accessing a variable can only be accessed, passed, or queried in two ways. The two ways are:

1. Access / pass variables by value

two。 Access / pass variables by address-this method is the pointer

There is no third way to access and pass variable values. A reference variable is a pointer variable, which also has memory space. The most important thing is that a reference is a pointer that will be dereferenced automatically by the compiler. Is it hard to believe?

Here is a simple C++ code that uses a reference

# include int main () {inti = 10; / / A simple integer variable int & j = I; / / A Reference to the variable i jamboree; / / Incrementing j will increment both i and j. / / check by printing values of i and j cout

Tags: Code variables compilers compilers pointers caches methods addresses that is statements statements articles interpretations same that is memory content situation mode space Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Redmi MySQL macOS OPPO Reno Xiaomi