Click here to Skip to main content
15,920,438 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
Questionsockets in vc6 Pin
shuchigo_jane18-May-06 21:52
shuchigo_jane18-May-06 21:52 
AnswerRe: sockets in vc6 Pin
Eytukan18-May-06 22:02
Eytukan18-May-06 22:02 
GeneralRe: sockets in vc6 Pin
shuchigo_jane18-May-06 22:14
shuchigo_jane18-May-06 22:14 
GeneralRe: sockets in vc6 Pin
Sarath C18-May-06 23:18
Sarath C18-May-06 23:18 
GeneralRe: sockets in vc6 Pin
shuchigo_jane18-May-06 23:25
shuchigo_jane18-May-06 23:25 
QuestionSingleton Class (C++) Pin
Scorpio18-May-06 21:51
Scorpio18-May-06 21:51 
AnswerRe: Singleton Class (C++) Pin
Cedric Moonen18-May-06 21:58
Cedric Moonen18-May-06 21:58 
GeneralRe: Singleton Class (C++) Pin
Stephen Hewitt18-May-06 22:06
Stephen Hewitt18-May-06 22:06 
A simpler way:
--------------

// Console.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <iostream>
using namespace std;

class Single
{
public:
static Single& GetInstance()
{
static Single s;
return s;
}

void Method() const
{
cout << "Method called : this = 0x" << hex << this << endl;
}

private:
Single()
{
cout << "Instance created!" << endl;
};
};



int main(int argc, char* argv[])
{
Single::GetInstance().Method();
Single::GetInstance().Method();
Single::GetInstance().Method();

return 0;
}

--------------
This technique leverages the langauges rules: A static member is created the first time it's encountered. This way we don't need the "new" or the "if" or to remember to "delete" it.

Steve
GeneralRe: Singleton Class (C++) Pin
Cedric Moonen18-May-06 22:13
Cedric Moonen18-May-06 22:13 
AnswerRe: Singleton Class (C++) Pin
Maxwell Chen18-May-06 21:59
Maxwell Chen18-May-06 21:59 
GeneralRe: Singleton Class (C++) Pin
Scorpio18-May-06 22:01
Scorpio18-May-06 22:01 
QuestionHow to send SMS in VC++ Pin
MadBoyz18-May-06 21:22
MadBoyz18-May-06 21:22 
AnswerRe: How to send SMS in VC++ Pin
Cedric Moonen18-May-06 21:30
Cedric Moonen18-May-06 21:30 
GeneralRe: How to send SMS in VC++ Pin
MadBoyz18-May-06 21:39
MadBoyz18-May-06 21:39 
AnswerRe: How to send SMS in VC++ Pin
Hamid_RT18-May-06 21:31
Hamid_RT18-May-06 21:31 
AnswerRe: How to send SMS in VC++ Pin
Eytukan18-May-06 21:34
Eytukan18-May-06 21:34 
GeneralRe: How to send SMS in VC++ Pin
Rajesh R Subramanian18-May-06 22:09
professionalRajesh R Subramanian18-May-06 22:09 
AnswerRe: How to send SMS in VC++ Pin
Hamid_RT18-May-06 21:34
Hamid_RT18-May-06 21:34 
AnswerRe: How to send SMS in VC++ Pin
_AnsHUMAN_ 18-May-06 23:00
_AnsHUMAN_ 18-May-06 23:00 
AnswerRe: How to send SMS in VC++ Pin
Laxman Auti18-May-06 23:53
Laxman Auti18-May-06 23:53 
GeneralRe: How to send SMS in VC++ Pin
MadBoyz19-May-06 5:32
MadBoyz19-May-06 5:32 
AnswerRe: How to send SMS in VC++ Pin
David Crow19-May-06 3:29
David Crow19-May-06 3:29 
GeneralRe: How to send SMS in VC++ Pin
MadBoyz19-May-06 5:36
MadBoyz19-May-06 5:36 
QuestionHow to set Version properties of the applications EXE file Pin
zahid_ash18-May-06 20:44
zahid_ash18-May-06 20:44 
AnswerRe: How to set Version properties of the applications EXE file Pin
Laxman Auti18-May-06 20:51
Laxman Auti18-May-06 20:51 

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.