// File: main2.C // // Using the Widget class, second version #include #include "widget2.h" //=========================================================== // Local function named "report" void report() ; void report() { cout << "This function is here just to be confusing\n" ; } //=========================================================== // Some functions with local Widgets void func1() { Widget a, b ; cout << "\nLocal variable a " ; a.display() ; cout << "\nLocal variable b " ; b.display() ; Widget::report() ; } void func2() { Widget c, d ; cout << "\nLocal variable c " ; c.display() ; cout << "\nLocal variable d " ; d.display() ; Widget::report() ; } void func3() { Widget e, f; cout << "\nLocal variable e " ; e.display() ; cout << "\nLocal variable f " ; f.display() ; Widget::report() ; func2() ; Widget::report() ; } //=========================================================== // main() { Widget::report() ; // get initial report Widget x ; cout << "\nWidget x " ; x.display() ; Widget y(15) ; cout << "\nWidget y " ; y.display() ; Widget::report() ; // get new report Widget A[5] ; Widget::report() ; // get new report cout << "\nWidget A[0] " ; A[0].display() ; cout << "\nWidget A[3] " ; A[3].display() ; cout << "\n\n---Calling func1()\n" ; func1() ; cout << "\n\n--- Return from func1()\n" ; Widget::report() ; cout << "\n\n---Calling func2()\n" ; func2() ; cout << "\n\n--- Return from func2()\n" ; Widget::report() ; cout << "\n\n---Calling func3()\n" ; func3() ; cout << "\n\n--- Return from func3()\n" ; Widget::report() ; // get final report }