Files Classes Functions Hierarchy
#include <iostream>#include <singletontest.h>#include <singleton.h>
Go to the source code of this file.
Functions | |
| void | singletontest01 () |
| void singletontest01 | ( | ) |
Definition at line 44 of file singletontest.cpp.
References init(), and print().
Referenced by main().
00045 { 00046 singletontest_cat c(23); 00047 cout << "Creating a singleton singletontest_cat object" << endl; 00048 cout << "This does not destruct the singletontest_cat when there "; 00049 cout << "are no references." << endl; 00050 { 00051 SingletonPtr<singletontest_cat> init(&c); 00052 } 00053 00054 cout << "Try accessing the singletontest_cat's print function." << endl; 00055 SingletonPtr<singletontest_cat>()->print(); 00056 00057 cout << endl << endl; 00058 00059 cout << "Reference count test" << endl; 00060 cout << "The singletontest_hat object is constructed and should be " << endl; 00061 cout << "destructed imediately when this singleton dies" << endl; 00062 00063 // Call delete on singletontest_hat(32) when out of scope. 00064 { 00065 SingletonPtr<singletontest_hat> (new singletontest_hat(32),SingletonPtr<singletontest_hat>::nonarray); 00066 } 00067 cout << "There are no longer any SingletonPtr<singletontest_hat> objects alive" << endl; 00068 00069 cout << endl; 00070 cout << "Reference Count test on arrays" << endl; 00071 cout << "Call delete[] when no SingletonPtr's exist" << endl; 00072 { 00073 SingletonPtr<singletontest_hat> (new singletontest_hat[5],SingletonPtr<singletontest_hat>::array); 00074 } 00075 cout << "The destructors for 5 singletontest_hat objects should have been called" << endl; 00076 }
1.5.8