#include #include #include "date.h" using namespace std; struct mystruct { int field1; int field2; }; int main() { mystruct s = {10, 20}; date d(12, 31, 2014); cout << s.field1 << "\n"; d.print(); cout << "\n\n"; //A pointer to a structure and a pointer to an object. mystruct *p1 = &s; date *p2 = &d; //Don't write this. cout << (*p1).field1 << "\n"; (*p2).print(); cout << "\n\n"; //Write this instead. cout << p1->field1 << "\n"; p2->print(); cout << "\n\n"; //A reference to a structure and a reference to an object mystruct& r1 = s; date& r2 = d; cout << r1.field1 << "\n"; r2.print(); cout << "\n"; return EXIT_SUCCESS; }