home *** CD-ROM | disk | FTP | other *** search
/ Microsoftware Monthly 19…2 Programming Power Tools / MASO9512.ISO / cpptutor / cpptutor.arj / CH09 / F092022.FLD < prev    next >
Encoding:
Text File  |  1993-10-06  |  2.0 KB  |  1 lines

  1. ╘// Example of overloading the () operator        Part 2 of 2                                     // Used to print a GradeAssoc                                                                      ostream╦& operator<<( ostream╦& os╦, Grade╦::GradeAssoc assoc╦)                     ╘// Define and initialize to associative array                                                    Grade╦::GradeAssoc                                                                            Grade╦::GradeList╦[] = { {"A"╦, {80╦, 100╦}}, {"B"╦, {70╦, 79╦}},                ╦{"C"╦, {60╦, 69╦}}, {"D"╦, {50╦, 59╦}}, {"F"╦, {0╦, 49╦}} };    ╦void main╦() {                                                                                   Grade x╦;╘                    // Create a grade object                                         GradeIterator next╦(x╦);╘      // Create an Initialize iterator                             Grade╦::GradeAssoc╦* pAssoc╦;                                                                          ╘ // a pointer to Grade pair {"A", {80, 100}}                                        ╦while (pAssoc ╦= next╦()) ╘    // Get the next grade pair                                    cout ╦<< *pAssoc ╦<< endl╦;╘ // print the grade pair                               ╦}