//To compile: g++ [source_code.cpp] -o [exec_file] // replace [soure_code.cpp] with the filename, // replace [exec_file] with the executable file name // i.e., g++ c++_basics.cpp -o run //Note: if the output redirect is not given, i.e., the "-o [exec_file]" part is missing // then the default executable name is a.out //To run the program, simply run the executable: ./[exec_file] // i.e., ./a.out (if your executable file is a.out) #include //input/output stream library using namespace std; void foo(int* p){ *p = 500; return; } //main function: entry point of the program int main() { int val = 50; int* ptr = &val; int** ptr2 = &ptr; cout << "val:" << val << endl; cout << "*ptr: " << *ptr << endl; cout << "**ptr2: "<< **ptr2 << endl; cout << "&val: " <<&val << endl; cout << "ptr: " << ptr << endl; cout << "*ptr2: "<< *ptr2 << endl; cout << "&ptr: " << &ptr << endl; cout << "ptr2: "<< ptr2 << endl; cout << "&ptr2: "<< &ptr2 << endl; // *ptr = 100; // cout << "val:" << val << endl; // foo(&val); // cout << "val:" << val << endl; return 0; }