Click here to Skip to main content
16,005,162 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionHow to display images dynamically Pin
Neeranjan10-Jun-04 18:23
Neeranjan10-Jun-04 18:23 
AnswerRe: How to display images dynamically Pin
Johan Rosengren10-Jun-04 21:15
Johan Rosengren10-Jun-04 21:15 
GeneralRe: How to display images dynamically Pin
Neeranjan10-Jun-04 23:20
Neeranjan10-Jun-04 23:20 
General.NET docakable class view Pin
flip10-Jun-04 16:00
flip10-Jun-04 16:00 
GeneralC++ questions: limiting number of class instantiation and volatile keyword Pin
Indrawati10-Jun-04 14:39
Indrawati10-Jun-04 14:39 
GeneralRe: C++ questions: limiting number of class instantiation and volatile keyword Pin
bikram singh10-Jun-04 15:25
bikram singh10-Jun-04 15:25 
GeneralRe: C++ questions: limiting number of class instantiation and volatile keyword Pin
Anonymous10-Jun-04 18:16
Anonymous10-Jun-04 18:16 
GeneralRe: C++ questions: limiting number of class instantiation and volatile keyword Pin
bikram singh10-Jun-04 18:35
bikram singh10-Jun-04 18:35 
Oops, sorry i didnt notice the 'delete this' is your code earlier.

Calling delete this for a stack-based object will cause an exception, because the stack cannot be "freed" until a function returns.

If you are using this technique in your code, you should not be using stack-based objects at all.

Consider this:

void First(void)<br />
{<br />
  MyClass a;<br />
}<br />
<br />
void Second(void)<br />
{<br />
  MyClass b;<br />
  First();<br />
}

In this scenario, how would you prevent the second stack-based object being created in the call to First() ?

For this reason, either you should only use object instantiation via the new operator, or use some a BOOL data member to disable unwanted-instances' functionality. The latter is ofcourse tedious, and prone to errors.

You could, throw an execption in the constructor when you detect that a class instance is not the first instance.
Then, in every place you use this class via stack/freestore, you could use exception handling.






Bikram Singh

GeneralRe: C++ questions: limiting number of class instantiation and volatile keyword Pin
bikram singh10-Jun-04 18:41
bikram singh10-Jun-04 18:41 
GeneralRe: C++ questions: limiting number of class instantiation and volatile keyword Pin
palbano10-Jun-04 15:43
palbano10-Jun-04 15:43 
Questionhow to check if BDE installed Pin
kzyczynski10-Jun-04 12:18
kzyczynski10-Jun-04 12:18 
AnswerRe: how to check if BDE installed Pin
bikram singh10-Jun-04 15:32
bikram singh10-Jun-04 15:32 
QuestionExecuting EXE from Memory? Pin
NodeX10-Jun-04 11:35
NodeX10-Jun-04 11:35 
AnswerRe: Executing EXE from Memory? Pin
Neville Franks10-Jun-04 12:09
Neville Franks10-Jun-04 12:09 
AnswerRe: Executing EXE from Memory? Pin
David Crow10-Jun-04 16:48
David Crow10-Jun-04 16:48 
GeneralRe: Executing EXE from Memory? Pin
NodeX10-Jun-04 21:37
NodeX10-Jun-04 21:37 
GeneralRe: Executing EXE from Memory? Pin
David Crow11-Jun-04 2:10
David Crow11-Jun-04 2:10 
GeneralRe: Executing EXE from Memory? Pin
NodeX11-Jun-04 5:10
NodeX11-Jun-04 5:10 
GeneralRe: Executing EXE from Memory? Pin
David Crow11-Jun-04 5:32
David Crow11-Jun-04 5:32 
GeneralRe: Executing EXE from Memory? Pin
NodeX11-Jun-04 5:39
NodeX11-Jun-04 5:39 
GeneralRe: Executing EXE from Memory? Pin
David Crow11-Jun-04 6:23
David Crow11-Jun-04 6:23 
GeneralRe: Executing EXE from Memory? Pin
Alexander M.,11-Jun-04 7:09
Alexander M.,11-Jun-04 7:09 
AnswerRe: Executing EXE from Memory? Pin
bikram singh10-Jun-04 18:16
bikram singh10-Jun-04 18:16 
GeneralModeless Dialog in DLL: Message Confusion Pin
Justin Cooke10-Jun-04 11:31
Justin Cooke10-Jun-04 11:31 
GeneralRe: Modeless Dialog in DLL: Message Confusion Pin
bikram singh10-Jun-04 19:02
bikram singh10-Jun-04 19:02 

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.