After searching through this forum and other forums relating to C++ and Dynamic Memory; I would like to know the indepth reason on why do you have to declare a dynamic memory allocation in either a Class or in a function for the program to compile?
e.g.
//place a dynamic memory allocation here and the program won't compile
int main (void)
{
int * Total_N;
Total_N = new int; //place a dynamic memory allocation here and the program compiles
}
As the book I'm learning from doesn't go into an indepth explanation, so any help would be appreciated. Thank you.