Click here to Skip to main content
15,907,913 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: ActiveX question Pin
led mike6-Mar-08 5:54
led mike6-Mar-08 5:54 
GeneralRe: ActiveX question Pin
Mark Salsbery6-Mar-08 6:23
Mark Salsbery6-Mar-08 6:23 
Generalhehehe well he did ask [modified] Pin
led mike6-Mar-08 9:06
led mike6-Mar-08 9:06 
GeneralRe: hehehe well he did ask Pin
Mark Salsbery6-Mar-08 9:14
Mark Salsbery6-Mar-08 9:14 
QuestionLoosing interfaces function in Single Instance Application with a Class having multiple heritance Pin
ochoteau6-Mar-08 5:00
ochoteau6-Mar-08 5:00 
GeneralRe: Loosing interfaces function in Single Instance Application with a Class having multiple heritance Pin
Member 75496024-Mar-08 10:50
Member 75496024-Mar-08 10:50 
GeneralRegistering a Notification Handler with an Active Directory Server. Pin
johnalek6-Mar-08 3:58
johnalek6-Mar-08 3:58 
QuestionWhat is cl_login in MFC? Pin
Nikesh Jagtap6-Mar-08 3:10
Nikesh Jagtap6-Mar-08 3:10 
AnswerRe: What is cl_login in MFC? Pin
Hamid_RT9-Mar-08 1:06
Hamid_RT9-Mar-08 1:06 
Generalmemory usage keeps on increasing Pin
jalsa G6-Mar-08 2:09
jalsa G6-Mar-08 2:09 
GeneralRe: memory usage keeps on increasing Pin
CPallini6-Mar-08 2:14
mveCPallini6-Mar-08 2:14 
GeneralRe: memory usage keeps on increasing Pin
toxcct6-Mar-08 2:18
toxcct6-Mar-08 2:18 
GeneralRe: memory usage keeps on increasing Pin
jalsa G6-Mar-08 2:26
jalsa G6-Mar-08 2:26 
GeneralRe: memory usage keeps on increasing Pin
toxcct6-Mar-08 2:39
toxcct6-Mar-08 2:39 
QuestionRe: memory usage keeps on increasing Pin
CPallini6-Mar-08 2:54
mveCPallini6-Mar-08 2:54 
QuestionWhy this code doesn't crash? Pin
ComplexLifeForm6-Mar-08 1:51
ComplexLifeForm6-Mar-08 1:51 
Hi,

Recently a friend of mine who is learning C++ wrote a code as given below

class SingleTon
{
public:
static SingleTon& GetInstance()
{
return *ptr;
}

private:
static SingleTon* ptr;
};

SingleTon* SingleTon::ptr = NULL;

int _tmain()
{
SingleTon &ref = SingleTon::GetInstance();

if(&ref == NULL)
{
cout << "The reference is NULL";
}

return 0;
}

My query is why didn't this code crashed. The program simply printed "The reference is NULL" and exited. I am a bit confused here, The pointer is initialized to NULL and in GetInstance() it is dereferenced. In my opinion as soon as it was dereferenced, the program should have crashed!! Or is there something basic I am missing?

Thanks & Regards
Confused | :confused: Confused | :confused:
AnswerRe: Why this code doesn't crash? Pin
CPallini6-Mar-08 1:59
mveCPallini6-Mar-08 1:59 
AnswerRe: Why this code doesn't crash? Pin
toxcct6-Mar-08 2:17
toxcct6-Mar-08 2:17 
GeneralRe: Why this code doesn't crash? Pin
CPallini6-Mar-08 2:22
mveCPallini6-Mar-08 2:22 
GeneralRe: Why this code doesn't crash? Pin
toxcct6-Mar-08 2:25
toxcct6-Mar-08 2:25 
GeneralRe: Why this code doesn't crash? Pin
CPallini6-Mar-08 2:45
mveCPallini6-Mar-08 2:45 
GeneralRe: Why this code doesn't crash? Pin
ComplexLifeForm6-Mar-08 2:23
ComplexLifeForm6-Mar-08 2:23 
AnswerRe: Why this code doesn't crash? Pin
Doc Lobster6-Mar-08 2:46
Doc Lobster6-Mar-08 2:46 
AnswerRe: Why this code doesn't crash? Pin
Roger Stoltz6-Mar-08 3:01
Roger Stoltz6-Mar-08 3:01 
AnswerRe: Why this code doesn't crash? Pin
Rajkumar R6-Mar-08 3:39
Rajkumar R6-Mar-08 3:39 

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.