Click here to Skip to main content
15,896,606 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Problems with .NET double data type Pin
toxcct12-Sep-05 0:18
toxcct12-Sep-05 0:18 
GeneralRe: Problems with .NET double data type Pin
sirtimid12-Sep-05 0:42
sirtimid12-Sep-05 0:42 
GeneralRe: Problems with .NET double data type Pin
toxcct12-Sep-05 1:44
toxcct12-Sep-05 1:44 
GeneralRe: Problems with .NET double data type Pin
sirtimid12-Sep-05 21:54
sirtimid12-Sep-05 21:54 
GeneralRe: Problems with .NET double data type Pin
Maximilien12-Sep-05 3:04
Maximilien12-Sep-05 3:04 
QuestionHow to trap as soon as some Windows app of the same computer sends a print job to the network printer server? Pin
wangdave12-Sep-05 0:05
wangdave12-Sep-05 0:05 
Questionsingleton for a parent with protected destructor Pin
yccheok12-Sep-05 0:02
yccheok12-Sep-05 0:02 
AnswerRe: singleton for a parent with protected destructor Pin
Axter12-Sep-05 0:34
professionalAxter12-Sep-05 0:34 
This is a non-compliant issue with VC++ compiler. The code should
compile, but it will not in VC++ 6.0 or 7.1.

As a workaround, you can create a friend class and let it delete your
singleton.
Here's a workaround example:
template<typename t="">
class Singleton
{
protected:
Singleton(){}
~Singleton(){}
Singleton(const Singleton&);
Singleton& operator=(const Singleton&);
public:
class FriendClass
{
public:
FriendClass():m_MyClass(new T()){}
~FriendClass(){delete m_MyClass;}
T* m_MyClass;
};
static T& Instance() {
static FriendClass Instance;
return *Instance.m_MyClass;
//Will not compile with the following code in VC++ 6.0 or 7.1
// static T Instance;
// return Instance;
}



};


//The above Singleton template can be used two ways.
//Either by deriving from it, or by declaring the friend class with
fully
//qualified template, and calling the instance member function with
fully
//qualified template function.

class Widget {
private:
Widget(){}
~Widget(){}
Widget& operator=(const Widget&);
Widget(const Widget&);
public:
friend class Singleton<widget>::FriendClass;
int m_i;



};


class foo : public Singleton<foo>{
private:
foo(){}
~foo(){}
foo& operator=(const foo&);
foo(const foo&);
public:
friend class FriendClass;
int m_i;


};


int main(int, char*)
{
Widget& MyWidget = Singleton<widget>::Instance();
foo& Myfoo = foo::Instance();


Top ten member of C++ Expert Exchange.
http://www.experts-exchange.com/Cplusplus
QuestionAbout System Menu == Plz Help Urgent Pin
parims11-Sep-05 23:44
parims11-Sep-05 23:44 
AnswerRe: About System Menu == Plz Help Urgent Pin
toxcct12-Sep-05 0:15
toxcct12-Sep-05 0:15 
AnswerRe: About System Menu == Plz Help Urgent Pin
ThatsAlok12-Sep-05 23:56
ThatsAlok12-Sep-05 23:56 
Questionvb to c++ Pin
Barm11-Sep-05 22:58
Barm11-Sep-05 22:58 
AnswerRe: vb to c++ Pin
S Douglas12-Sep-05 1:50
professionalS Douglas12-Sep-05 1:50 
AnswerRe: vb to c++ Pin
David Crow12-Sep-05 3:45
David Crow12-Sep-05 3:45 
Questionwatching unicode strings during debugging Pin
Chintoo72311-Sep-05 22:50
Chintoo72311-Sep-05 22:50 
AnswerRe: watching unicode strings during debugging Pin
Manfred Staiger11-Sep-05 23:19
Manfred Staiger11-Sep-05 23:19 
GeneralRe: watching unicode strings during debugging Pin
Chintoo72311-Sep-05 23:46
Chintoo72311-Sep-05 23:46 
GeneralRe: watching unicode strings during debugging Pin
Manfred Staiger12-Sep-05 0:05
Manfred Staiger12-Sep-05 0:05 
GeneralRe: watching unicode strings during debugging Pin
David Crow12-Sep-05 3:54
David Crow12-Sep-05 3:54 
AnswerRe: watching unicode strings during debugging Pin
Maximilien12-Sep-05 1:14
Maximilien12-Sep-05 1:14 
Questionseperate window at run time for image Pin
a_david12311-Sep-05 22:48
a_david12311-Sep-05 22:48 
Question[Message Deleted] Pin
a_david12311-Sep-05 22:29
a_david12311-Sep-05 22:29 
QuestionRe: Regards1creating new window Pin
toxcct11-Sep-05 22:41
toxcct11-Sep-05 22:41 
QuestionMultiple IE instance and cookies problem Pin
Shamael11-Sep-05 22:28
Shamael11-Sep-05 22:28 
Questioncatching NavigateComplete2 using win32 Pin
yair2211-Sep-05 21:58
yair2211-Sep-05 21:58 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.