Is there any difference between these 2 ways of storing an integer?
int X = 100;
and
int *pX = new int(100);
Is there any difference between these 2 ways of storing an integer?
int X = 100;
and
int *pX = new int(100);
"Is there any difference between these 2 ways of storing an integer?"
Yes, there is a significant difference.
int X = 100;
Initializes a variable X on the stack with the value 100, while
int *pX = new int(100);
allocates memory for an int on the heap, kept in pointer pX, and initializes the value to 100.
For the latter you should notice, that it's necessary to deallocate that heap memory, when it's no longer needed:
delete pX;
The first one is creating a variable on the stack while the second one is creating a variable on the heap and creating a pointer to point at it.