I am always confused with the concept "define variable." What does define mean?
For example:
void main {
map<int,int> *infoMap;
if() {
//some check here,if it passes this check, then new infoMap
}
infoMap = new infoMap;
}
So does
map<int,int> *infoMap;
or
map<int,int> *infoMap = new inforMap;
define a variable?
The top one is the declaration, or if you like, definition. Here, the compiler allocates space for the variable.
The bottom one is an assignment. Here, the compiler fills the space it allocated at definition time. You can have more than one assignment, if you want to change the value of the variable to something else.