home *** CD-ROM | disk | FTP | other *** search
- /* ------------------------------------------------------ */
- /* STATIC.CPP */
- /* Initializing Static Class Members of Type Class */
- /* (c) 1991 Borland International */
- /* All rights reserved. */
- /* ------------------------------------------------------ */
- /* veröffentlicht in DOS toolbox 3'92 */
- /* ------------------------------------------------------ */
-
- // declare a class
- class First {
- public:
- int count;
- First() {} // must have callable constructor
- };
-
- // declare class containing static member of class First
-
- class Second {
- public:
- static First fVar;
- };
-
- // initialize static member of class Second
- First Second::fVar = First();
- // initialize with explicit call to ctor
-
- /* ------------------------------------------------------ */
-
- int main(void)
- {
- Second *sVarA = new Second;
- delete sVarA;
- return 0;
- }
- /* ------------------------------------------------------ */
- /* STATIC.CPP */
-