I tried to figure out how new works:
#include <iostream>
using namespace std;
struct munch{
    int x;
};
int main(){
    munch *a;
    //1
    cout << a << endl;
    cout << a->x << endl;
    //1
    cout << endl;
    //2
    a= new munch;
    cout << a << endl;
    cout << a->x << endl;
    //2
    cout << endl;
    //3
    a= new munch;
    cout << a << endl;
    cout << a->x << endl;
    //3
}
What's the difference between 1, 2 and 3? Why does the operator new gives the pointer to struct a new location but doesn't change the value of a->x? But before calling the first instance of new it has a different value than after calling new once?
 
     
     
     
     
     
     
     
    