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

C / C++ / MFC

 
Generalsave BMP to JPG Pin
kd834110-Mar-05 17:32
kd834110-Mar-05 17:32 
GeneralRe: save BMP to JPG Pin
V.10-Mar-05 21:09
professionalV.10-Mar-05 21:09 
GeneralRe: save BMP to JPG Pin
kd834111-Mar-05 4:15
kd834111-Mar-05 4:15 
GeneralRe: save BMP to JPG Pin
Mircea Puiu11-Mar-05 4:34
Mircea Puiu11-Mar-05 4:34 
GeneralRe: save BMP to JPG Pin
Chris Losinger11-Mar-05 6:18
professionalChris Losinger11-Mar-05 6:18 
GeneralVirtual Destructor Pin
Neelesh K J Jain10-Mar-05 17:09
Neelesh K J Jain10-Mar-05 17:09 
GeneralRe: Virtual Destructor Pin
Serge Krynine10-Mar-05 17:25
Serge Krynine10-Mar-05 17:25 
GeneralRe: Virtual Destructor Pin
Cedric Moonen10-Mar-05 20:55
Cedric Moonen10-Mar-05 20:55 
Neelesh K J Jain wrote:
What is the main advantage of Virtual destructor?

Imagine you have one base class (CBase) and one derived class (CChild that inherits from CBase). Now look at this piece of code:

CBase* pPtr = new CChild;<br />
....<br />
// Do things with pPtr..<br />
...<br />
delete pPtr;


Now, what would happens if the destructor wasn't virtual ? The only destructor that will be called is the destructor of the base class (pPtr is a pointer of type CBase*) and so your object may be not completelly cleaned. So, if you make your destructor virtual, the destructor of CChild will be called.


Neelesh K J Jain wrote:
Why don't we have virtual constructor when virtual destructor's are present?

Because when you create an instance of an object (like in the piece of code before), you know exactly which kind of class (CChild or CBase) you want to create. In fact this line: CBase* pPtr = new CChild can be explained as: first create an object of type CChild (the compiler knows exactly that he will need to call the constructor of CChild) and then store this pointer in pPtr.
So, here, no need for virtual constructors...

Hope this helps
QuestionHow to control mouse to select area ? Pin
RobertHuang10-Mar-05 15:49
RobertHuang10-Mar-05 15:49 
QuestionOleLoadFromStream?? Pin
Anonymous10-Mar-05 11:09
Anonymous10-Mar-05 11:09 
Generalplease help me Pin
ali elba10-Mar-05 10:57
sussali elba10-Mar-05 10:57 
GeneralRe: please help me Pin
David Crow11-Mar-05 4:59
David Crow11-Mar-05 4:59 
GeneralRe: please help me Pin
Anonymous11-Mar-05 6:57
Anonymous11-Mar-05 6:57 
GeneralRe: please help me Pin
David Crow11-Mar-05 7:25
David Crow11-Mar-05 7:25 
GeneralVisual C++.Net Pin
jogodo10-Mar-05 10:16
jogodo10-Mar-05 10:16 
GeneralRe: Visual C++.Net Pin
Serge Krynine10-Mar-05 12:49
Serge Krynine10-Mar-05 12:49 
QuestionHiw can I make "Visual C++ 6 Components"? Pin
Behzad Ebrahimi10-Mar-05 9:55
Behzad Ebrahimi10-Mar-05 9:55 
Generalpopupmenu language Pin
coolice200210-Mar-05 9:05
coolice200210-Mar-05 9:05 
GeneralRe: popupmenu language Pin
Mircea Puiu11-Mar-05 4:44
Mircea Puiu11-Mar-05 4:44 
GeneralUse of Registry WriteProfileString Pin
jerry1211a10-Mar-05 8:37
jerry1211a10-Mar-05 8:37 
GeneralRe: Use of Registry WriteProfileString Pin
Chris Meech10-Mar-05 9:05
Chris Meech10-Mar-05 9:05 
GeneralRe: Use of Registry WriteProfileString Pin
David Crow10-Mar-05 10:00
David Crow10-Mar-05 10:00 
GeneralMFC Open Dialog Pin
Anonymous10-Mar-05 8:00
Anonymous10-Mar-05 8:00 
GeneralRe: MFC Open Dialog Pin
Steen Krogsgaard 210-Mar-05 8:08
Steen Krogsgaard 210-Mar-05 8:08 
GeneralI'm puzzled Pin
g3e10-Mar-05 7:57
g3e10-Mar-05 7:57 

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.