In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >
Share
Shulou(Shulou.com)06/01 Report--
Stick a code to occupy the position, and there will be time to make up the pointer function and function pointer.
# include using namespace std;void freePtr1 (int* p1) {/ * before releasing memory-> p1 Address: 0012FDDC p1 value: 003429B8, here, p1 it is also a variable, since it is a variable, then it will pass the value of the external variable p1 to the stack, generating an address in the stack: 0012FDDC, of course, its value will still point to the heap address: 003429B8. * / delete p1; / / the system reclaims the memory at the address 003429B8 of the p1 value. P1 = NULL;// assigns a NULL value to p1 that is: 00000000. Note: the address of p1 itself has not changed, but the value of p1 has changed. / / after releasing memory-> p1 Address: 0012FDDC p1 value: 00000000 / /. After unstack, p1 is automatically regarded as invalid because it is a temporary object. } void freePtr2 (int*& p2) {/ * before releasing memory-> p2 Address: 0012FEC8 p2 value: 003429B8, p2 is a reference to a pointer, that is, a reference points to a pointer. Remember the characteristics of the reference: direct operation on the referenced object. So its address and value are the same as the value of p2 in the main () function off the stack. * / delete p2; / / A pair of pointers referenced by p2 releases memory, that is, the system reclaims the memory at the 003429B8 address of the value of p2 in the main () function. P2 = NULL;// assigns null to the pointer to p2 in the main () function. / / after releasing memory-> p2 Address: 0012FEC8 p2 value: 00000000, / / because the objects you operate on are p2 in the main () function, it will be applied to the original variable. } int main () {int * p1 = new int [1]; / / before releasing memory-> p1 Address: 0012FED4 p1 value: 003429B8 freePtr1 (p1); / / after releasing memory-> p1 Address: 0012FED4 p1 value: 003429B8 int * p2 = new int [1]; / / before releasing memory-> p2 Address: 0012FEC8 p2 value: 003429B8 freePtr2 (p2); / / * &. / / after releasing memory-> p2 Address: 0012FEC8 p2 value: 00000000}
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.