// example illustrating the syntax for accessing data in nested structures #include #include using namespace std; struct Date { int month; int day; int year; }; struct Employee { char firstName[20]; char lastName[20]; Date hireDate; Date birthDate; }; int main() { Employee emp; // emp is an employee variable Employee emp2 = { "John", "Smith", {6, 10, 2003}, {2, 19, 1981} }; // Set the name to "Alice Jones" strcpy(emp.firstName, "Alice"); strcpy(emp.lastName, "Jones"); // set the hire date to March 14, 2001 emp.hireDate.month = 3; emp.hireDate.day = 14; emp.hireDate.year = 2001; // sets the birth date to Sept 15, 1972 emp.birthDate.month = 9; emp.birthDate.day = 15; emp.birthDate.year = 1972; cout << "\nEmployee 1:\n"; cout << " Name: " << emp.firstName << ' ' << emp.lastName << '\n'; cout << " Birthdate: " << emp.birthDate.month << '/' << emp.birthDate.day << '/' << emp.birthDate.year << '\n'; cout << " Hire date: " << emp.hireDate.month << '/' << emp.hireDate.day << '/' << emp.hireDate.year << '\n'; cout << "\nEmployee 2:\n"; cout << " Name: " << emp2.firstName << ' ' << emp2.lastName << '\n'; cout << " Birthdate: " << emp2.birthDate.month << '/' << emp2.birthDate.day << '/' << emp2.birthDate.year << '\n'; cout << " Hire date: " << emp2.hireDate.month << '/' << emp2.hireDate.day << '/' << emp2.hireDate.year << '\n'; }