In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-21 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly explains "the concept of pointer passing and function return in C++", interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Next, let the editor take you to learn the concept of pointer passing and function return in C++.
When a pointer variable is passed to a function as an argument, the compiler will Copy a copy of the pointer variable, which means that the parameter variable used inside the function is another pointer variable.
From the output of the program, you can see that the address of the pointer variable inside fun () becomes another value. However, the memory location pointed to by the pointer variable inside fun () does not change. If you change the value of the memory location inside the function, the corresponding value of the pointer variable an outside of fun () will also be changed.
As can be seen from the output of the program, the pointer variable returned by fun () is also copy to the external pointer variable b, but the pointer variable b points to the original memory space.
Summary:
Through the above two programs, and their output results, we can see that when the pointer variable is passed to the function as a parameter, it is no different from the normal non-pointer variable. It is a new variable of copy. It's just that different pointer variables can all point to the same memory space, so that as long as the value in the memory space that the pointer variable points to changes, so does the value corresponding to the pointer variable of the passed parameter.
By the same token, the same is true when the return value of a function is a pointer variable.
At this point, I believe you have a deeper understanding of "the concept of pointer passing and function return in C++". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.