From: Gokhan Kisacikoglu <kisa@centropolisfx.com>
To: Brad Douglas <brad.douglas@saabsystems.com.au>
Cc: gcc-help@gcc.gnu.org
Subject: Re: problems with undefined references
Date: Tue, 25 Jun 2002 10:04:00 -0000 [thread overview]
Message-ID: <3D18A381.AEB823CB@centropolisfx.com> (raw)
In-Reply-To: <7DA8A54A920E1441960C129BDDFE4E9A042390@dr-honeydew.saabsystems.com.au>
[-- Attachment #1: Type: text/plain, Size: 165 bytes --]
Here I fixed your source code and attached it. You did not declare the
static variable anywhere, it is also safer to call the static variable
with its scope.
Gokhan
[-- Attachment #2: Singleton.cpp --]
[-- Type: text/plain, Size: 1470 bytes --]
#include "Singleton.h"
//=========================================================================
// Singleton class implementation
// only the default constructor is implemented as it is the only constructor
// that will be used so we will not get "undefined references" for the copy
// constructor and assignment operator when linking
//
SingletonDestroyer Singleton :: destroyer;
//-------------------------------------------------------------------------
// initialize the pointer to the single isntance
Singleton* Singleton::instance = 0;
//-------------------------------------------------------------------------
// default constructor (just initialises imlp)
Singleton::Singleton()
{
}
//-------------------------------------------------------------------------
// getInstance:
// if NULL construct the sinle instance, otherwise just return it
Singleton* Singleton::getInstance()
{
// is it the first call?
if (instance == 0)
{
// create sole instance
instance = new Singleton;
Singleton :: destroyer.setSingleton(instance);
}
// return the address of sole instance
return instance;
}
Singleton::~Singleton()
{
}
//=========================================================================
// SingletonDestroyer class implementation
SingletonDestroyer::~SingletonDestroyer()
{
delete instance;
}
void SingletonDestroyer::setSingleton( SingletonPtr _instance)
{
instance = _instance;
}
prev parent reply other threads:[~2002-06-25 17:04 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-06-25 1:58 Brad Douglas
2002-06-25 10:04 ` Gokhan Kisacikoglu [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3D18A381.AEB823CB@centropolisfx.com \
--to=kisa@centropolisfx.com \
--cc=brad.douglas@saabsystems.com.au \
--cc=gcc-help@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).