#include <iostream>

using namespace std;


int f(){
    double d;
    cout << "address of d: " << &d << endl;
    return 7;
}

void g(){
    int x;
    cout << "address of x: " << &x << endl;
}


int main(){
    //main goes on stack first, with space for int x
    int x;
    cout << "address of x in main: " << &x << endl;

    f();//f goes on stack, comes off
    g();//g goes on stack, comes off

    int * myIntPtr = new int; //asterisk as pointer declaration
    * myIntPtr = 7;//asterisk as dereferencing address
    cout << "value in new space is " << *myIntPtr  << endl;
    cout << "address of new space is " << &*myIntPtr  << endl;
    cout << "value in new space is " << *&*myIntPtr  << endl;
    cout << "address of new space is " << myIntPtr  << endl;

    return 0;
}

