Click here to Skip to main content
15,895,011 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
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 
GeneralRe: Why this code doesn't crash? Pin
ComplexLifeForm6-Mar-08 22:53
ComplexLifeForm6-Mar-08 22:53 
GeneralRe: Why this code doesn't crash? Pin
Rajkumar R6-Mar-08 23:43
Rajkumar R6-Mar-08 23:43 
GeneralRe: Why this code doesn't crash? Pin
ComplexLifeForm6-Mar-08 23:58
ComplexLifeForm6-Mar-08 23:58 
Thanks Rajkumar for the explaintion

But I do have more queries. If I add a member method like this

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

std::string GetClassName()
{
return std::string("SingleTon Class");
}

private:
static SingleTon* ptr;
};
and access it like this

SingleTon& ref = SingleTon::GetInstance();
std::string className = ref.GetClassName();

cout << className.c_str();

The program doesn't crash and it prints the correct value. Can you please explain why it should print the correct value? Now we have a member variable also. Or is it the case that the since the method is not accessing the data member variable, it is not crashing and it is treated similar to empty class scenario?

Thanks
Confused | :confused: Confused | :confused:
AnswerRe: Why this code doesn't crash? Pin
Rajkumar R7-Mar-08 0:42
Rajkumar R7-Mar-08 0:42 
GeneralGet Time Zone string Pin
Monty26-Mar-08 1:11
Monty26-Mar-08 1:11 
AnswerRe: Get Time Zone string Pin
cagespear6-Mar-08 2:15
cagespear6-Mar-08 2:15 
QuestionShell Namespace Extension under common file dialog Pin
zuma776-Mar-08 1:06
zuma776-Mar-08 1:06 
Questionchar[260] to LPWSTR conversion error?????? Pin
TooShy2Talk6-Mar-08 0:20
TooShy2Talk6-Mar-08 0:20 
AnswerRe: char[260] to LPWSTR conversion error?????? Pin
toxcct6-Mar-08 0:32
toxcct6-Mar-08 0:32 
AnswerRe: char[260] to LPWSTR conversion error?????? Pin
rowdy_vc++6-Mar-08 0:34
rowdy_vc++6-Mar-08 0:34 
GeneralRe: char[260] to LPWSTR conversion error?????? Pin
Rajesh R Subramanian6-Mar-08 0:44
professionalRajesh R Subramanian6-Mar-08 0:44 
GeneralRe: char[260] to LPWSTR conversion error?????? Pin
toxcct6-Mar-08 0:45
toxcct6-Mar-08 0:45 
GeneralRe: char[260] to LPWSTR conversion error?????? Pin
Maxwell Chen6-Mar-08 1:28
Maxwell Chen6-Mar-08 1:28 
GeneralRe: char[260] to LPWSTR conversion error?????? Pin
TooShy2Talk6-Mar-08 2:01
TooShy2Talk6-Mar-08 2:01 
GeneralRe: char[260] to LPWSTR conversion error?????? Pin
toxcct6-Mar-08 2:15
toxcct6-Mar-08 2:15 
GeneralRe: char[260] to LPWSTR conversion error?????? Pin
CPallini6-Mar-08 2:19
mveCPallini6-Mar-08 2:19 
QuestionFunctions pointed to by objects using Dynamic cast Pin
sp->tj6-Mar-08 0:11
sp->tj6-Mar-08 0:11 
GeneralRe: Functions pointed to by objects using Dynamic cast Pin
Rajkumar R6-Mar-08 0:13
Rajkumar R6-Mar-08 0:13 
GeneralRe: Functions pointed to by objects using Dynamic cast Pin
CPallini6-Mar-08 0:14
mveCPallini6-Mar-08 0:14 
Generalconnect to SQL server via the internet Pin
realtimeforme6-Mar-08 0:04
realtimeforme6-Mar-08 0:04 

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.