Click here to Skip to main content
15,909,199 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Image Skew(angle) Pin
Luc3426-Aug-10 4:22
Luc3426-Aug-10 4:22 
AnswerRe: Image Skew(angle) Pin
Chris Losinger26-Nov-07 2:14
professionalChris Losinger26-Nov-07 2:14 
QuestionHow to convert initialize an unsigned char* Pin
prithaa25-Nov-07 23:45
prithaa25-Nov-07 23:45 
AnswerRe: How to convert initialize an unsigned char* Pin
Cedric Moonen25-Nov-07 23:58
Cedric Moonen25-Nov-07 23:58 
GeneralRe: How to convert initialize an unsigned char* Pin
prithaa26-Nov-07 1:28
prithaa26-Nov-07 1:28 
GeneralRe: How to convert initialize an unsigned char* Pin
Cedric Moonen26-Nov-07 1:39
Cedric Moonen26-Nov-07 1:39 
JokeRe: How to convert initialize an unsigned char* Pin
Rajesh R Subramanian26-Nov-07 2:28
professionalRajesh R Subramanian26-Nov-07 2:28 
QuestionVirtual Destructor Pin
Andy Rama25-Nov-07 23:35
Andy Rama25-Nov-07 23:35 
class A<br />
{<br />
	int i;<br />
<br />
public :<br />
	A()<br />
	{<br />
		i = 0;<br />
	}<br />
	~A()<br />
	{<br />
		i = 0;<br />
	}<br />
};<br />
main()<br />
{<br />
     A *obj = new A[0];<br />
     if( obj != NULL )<br />
     {<br />
	delete[] obj;<br />
	obj = NULL;<br />
     }<br />
}<br />


Above code work well. But when I add virtual keyword to destructor of class then my program crashes.

class A<br />
{<br />
	int i;<br />
<br />
public :<br />
	A()<br />
	{<br />
		i = 0;<br />
	}<br />
	virtual ~A()<br />
	{<br />
		i = 0;<br />
	}<br />
};<br />
main()<br />
{<br />
     A *obj = new A[0];<br />
     if( obj != NULL )<br />
     {<br />
	delete[] obj;      //Crashes Here. Why?<br />
	obj = NULL;<br />
     }<br />
}


Why this crash occurs? If am I doing anything wrong? Or Is there any solution to avoid the crash?

Please help me.
AnswerRe: Virtual Destructor Pin
CPallini25-Nov-07 23:54
mveCPallini25-Nov-07 23:54 
GeneralRe: Virtual Destructor Pin
Matthew Faithfull26-Nov-07 0:15
Matthew Faithfull26-Nov-07 0:15 
AnswerRe: Virtual Destructor Pin
peterchen26-Nov-07 2:57
peterchen26-Nov-07 2:57 
QuestionCalling few functions inside a single function. Pin
CodingLover25-Nov-07 23:19
CodingLover25-Nov-07 23:19 
AnswerRe: Calling few functions inside a single function. Pin
Nelek26-Nov-07 0:53
protectorNelek26-Nov-07 0:53 
GeneralRe: Calling few functions inside a single function. Pin
CodingLover26-Nov-07 17:25
CodingLover26-Nov-07 17:25 
AnswerRe: Calling few functions inside a single function. Pin
David Crow26-Nov-07 7:09
David Crow26-Nov-07 7:09 
GeneralRe: Calling few functions inside a single function. Pin
CodingLover26-Nov-07 17:31
CodingLover26-Nov-07 17:31 
GeneralRe: Calling few functions inside a single function. Pin
Nelek26-Nov-07 20:03
protectorNelek26-Nov-07 20:03 
GeneralRe: Calling few functions inside a single function. Pin
CodingLover26-Nov-07 21:24
CodingLover26-Nov-07 21:24 
GeneralRe: Calling few functions inside a single function. Pin
Nelek27-Nov-07 2:43
protectorNelek27-Nov-07 2:43 
QuestionHow to view the resources used by the project ? Pin
keyto25-Nov-07 23:10
keyto25-Nov-07 23:10 
AnswerRe: How to view the resources used by the project ? Pin
Hamid_RT26-Nov-07 0:02
Hamid_RT26-Nov-07 0:02 
AnswerRe: How to view the resources used by the project ? Pin
Priya_Sundar26-Nov-07 0:05
Priya_Sundar26-Nov-07 0:05 
GeneralRe: How to view the resources used by the project ? Pin
keyto26-Nov-07 0:35
keyto26-Nov-07 0:35 
Questionneed your help Pin
zhiyuan1625-Nov-07 23:07
zhiyuan1625-Nov-07 23:07 
AnswerI think the error message is clear Pin
CPallini25-Nov-07 23:18
mveCPallini25-Nov-07 23:18 

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.