// struct-access.cpp // Illustrate the dange of liberal access // to a struct variable's data members. #include using namespace std; struct TimePiece{ int hr, min; char merid; }; void display(TimePiece T); int main(){ TimePiece watch; watch.hr = 11; watch.min = 45; watch.merid = 'A'; cout << "The time is now: "; display(watch); cout << endl; watch.min += 40; cout << "40 minutes later: "; display(watch); cout << endl; return 0; } void display(TimePiece T){ cout << T.hr << ':'; if (T.min<10) cout << '0'; cout << T.min << ' '; cout << T.merid << 'M'; } /* The time is now: 11:45 AM 40 minutes later: 11:85 AM exercise: modify using a class instead of a struct. Write a constructor and update member functions. */