home *** CD-ROM | disk | FTP | other *** search
- ╘// 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 ╦}