In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article introduces the relevant knowledge of "what are the four areas of C++ memory?" in the operation of practical 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!
Code area:
As the name implies, it is the place where the code we write is stored, but it is important to note that it is binary code.
Note: all the written code we write (including comments, variables, statements, etc.) will be placed in the code area.
Territory-wide:
Store global, static variables and constants.
Note:
1. There is a part of the global area called the constant area, which stores constants, such as global variables modified by const, string constants, etc.
two。 Local variables are not placed in the global area.
Stack area
Automatically allocated and released by the compiler, storing the parameter values of the function, local variables, and so on. There's nothing to pay attention to.
Stacking area
It is allocated and released by the programmer. If the programmer does not release it, the program will be reclaimed by the operating system at the end of the program.
Note that in C++, malloc is mainly used to open up memory in the heap area, while new opens up memory in the free storage area (there doesn't seem to be much difference between the heap and the free storage area, which is an abstract concept of C++ based on new pairing).
I believe that you may be confused, how to distinguish so many variables, here is a look at the code:
# include using namespace std;int Q = 20; / / global variable const int w = 60; global variable int main () {int b = 40 modified by const; / create local variable static int e = 10; / / static local variable adds static before ordinary variable, which belongs to static variable 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.
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.