========================================================== ==================================
Title: (c ++ pointer) points to note later
Abstract:
Note:
Date: 2010.6.1
Name: Zhu minglei
========================================================== ==================================
(1) For pointer definition, I used to write char * pszMsg;
This writing method is not very good. It looks like char * is a data type. What if I write it like this?
Char * pszMsg, pszInfo; it seems that two char * type variables are defined, that is, pszMsg, and pszInfo are pointers to char objects. In fact, this is not the case. In this way, pszMsg is defined as a pointer, while pszInfo is just a common char variable. So we need to have a good habit in the future and keep it for a long time. The pointer is defined in the form of * with the variable name.
Define a pointer: char * pszMsg;
Define two pointers: char * pszMsg, * pszInfo;
Mixed definition: char * pszMsg, pszInfo;
......
It seems more standard.
(2) initialization is required when defining pointers.
Sometimes the Code seems to be okay, and the compilation is also 0 errors, but it will run and crash as soon as it runs. This is often caused by irrational use of pointers. It is very dangerous to use a pointer without initialization. You know your current two brushes and you cannot control them as you like. Please initialize them as you like. Direct to an object. If the object to be pointed to does not exist, initialize it to 0.