home *** CD-ROM | disk | FTP | other *** search
- // \EXAMPLES\EX0809M.CPP
-
- // a class declared inside a function - a local class
- // version for Microsoft Visual C++
- //-----------------------------------------------------------
-
- #include <iostream.h>
- //------------------------------------------------------------
- // declaration of function containing a local class
- void action();
-
- //-----------------------------------------------------------
- // main()
- void main()
- { cout << "calling function action()" << endl;
- action();
- cout << "done" << endl;
- }
-
- //----------------------------------------------------------
- // function action()
-
- void action()
- {
- static long time = 3600;
- int i;
- struct HMS {
- int hour, min, sec;
- // member function of a local class
- // - not allowed in Microsoft Virtual C++
- // void tick ()
- // { sec = time % 60;
- // //i++; // error
- // sec++;
- // /*...*/ }
- };
- HMS now;
- cout << "Microsoft Visual C++ does not allow" << endl;
- cout << " member functions in local classes" << endl;
- //now.tick();
- //...
- }
-