Re: New kid in the block
No Its corrrect
When you need to construct a object for this singleton pattern you just call static function
static Logger* instance()
static Logger* instance()
code of this fuction can be as
Logger* Logger::instance()
{
if ( !loggerObj )
{
/* No instance has been created yet */
loggerObj = new Logger() ;
}
{
if ( !loggerObj )
{
/* No instance has been created yet */
loggerObj = new Logger() ;
}
use this intance just use as
Logger::instance()-><<fuction of Logger class>>
On 10/21/05, wang.wenlin <wang.wenlin@gmail.com> wrote:
static Logger *loggerObj ;
I think this is the problem.
It may be:
static Logger loggerObj;
NOT THE STAR.
So, it is constructed by itself.
BTW:
Do not forget to place this in your cpp file:
Logger Logger::loggerObj;
Good Lucky~!
0 Comments:
Post a Comment
<< Home