#include
<stdio.h>
#include
<stdlib.h>
class
Singleton
{
Singleton
(
void
){}//构造函数为私有的
static
Singleton
*
pSingleton
;
public
:
static
Singleton
*
CreateSingleton
()
{
if
(
pSingleton
==
NULL
)
{
pSingleton
=
new
Singleton
;
}
return
pSingleton
;
}
void
Output
()
{
printf
(
"asdasdasd\n"
);
}
};
Singleton
*
Singleton
::
pSingleton
=
NULL
; //必须初始化
void
main
()
{
Singleton
::
CreateSingleton
()->
Output
();
Singleton
::
CreateSingleton
()->
Output
();
getchar
();
return
;
}