home *** CD-ROM | disk | FTP | other *** search
- #if 0
- From:
- Subject: A failure of temporary destructors to be called
- Status: Fixed in ZTC++ 2.2
- #endif
-
- //_ bug34.cpp
-
- #include <stdio.h>
- #include <string.h>
-
- struct myClass
- {
- myClass(char*);
- ~myClass();
- int sernum;
- static int snc;
- };
-
- myClass::sernum=0;
-
- myClass::myClass(char* pc)
- {
- sernum = ++snc;
- printf("Constructing %d...\n",sernum);
- }
-
- myClass::~myClass()
- {
- snc--;
- printf("Destroying %d...\n",sernum);
- }
-
- int countDown(myClass & x)
- {
- static int i = 5;
- printf("countDown %d...\n",i--);
- return (i);
- }
-
- void main()
- {
- while( countDown("xyz"))
- ;
- }
-
- /* OUTPUT:
- Constructing 1...
- countDown5...
- Constructing 2...
- countDown4...
- Constructing 3...
- countDown3...
- Constructing 4...
- countDown2...
- Constructing 5...
- countDown1...
- Destroying 5...
- */
-