MEMORY: | | addr | | | | |=======| 123 |x: 72 |<--- |=======| \ | | | | | | | | | | | | |=======| / |p: 123------ |=======| | | | | | | | | -------------------------- float x = 5, y = 9; float *p = &x, *q = &y; *p = 17.0; *q = *p; // y = 17 q = p; // q points to whatever p points to // (copy the memloc value) *q = 13.0; cout << x << endl; cout << y << endl; -------------------------- p---->x: 13 q-----^ y: 17 PREDICT THE OUTPUT: 13 17 --------------------------------- int x = 10, y = 15; int *a = &x; cout << x << " " << y << endl; int *b = &y; // int *b; b = &y; *a = x * *b; // 10 * 15 = 150 cout << x << " " << y << endl; int *c = b; // int *c; c = b; *c = 25; cout << x << " " << y << endl; --------------------------------- a--->x: 150 b--->y: 25 ^ | c PREDICT THE OUTPUT: 10 15 150 15 150 25 int x = 0; int *m = NULL; cout << *m << endl; // CRASH! [0] ------------------------------- a--->| | | | | | | | | | | ------------------------------- ^ p p++ ==> p = p + sizeof( double ) Define a new data type: (1) attributes (2) operations on those attributes class Employee { private: string lname, fname; int id; string addr1, addr2, city, state, zip; public: // constructors // accessor functions // mutator functions }; // in main() Date d1(); Date d2( 1, 1, 2003 ); if ( d1.isEqual( d2 ) ) { // dates are equal! } if ( d1.isLeapYear() ) { // ... }