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

C / C++ / MFC

 
GeneralRe: I am Sergeant Destructor! (best practice Q) Pin
BlackSmith30-Jul-02 3:40
BlackSmith30-Jul-02 3:40 
GeneralRe: I am Sergeant Destructor! (best practice Q) Pin
Andrew Peace30-Jul-02 7:27
Andrew Peace30-Jul-02 7:27 
GeneralRe: I am Sergeant Destructor! (best practice Q) Pin
Paul Watson30-Jul-02 11:35
sitebuilderPaul Watson30-Jul-02 11:35 
GeneralCEdit style Pin
Renjith Ramachandran29-Jul-02 23:46
Renjith Ramachandran29-Jul-02 23:46 
GeneralRe: CEdit style Pin
PJ Arends30-Jul-02 0:28
professionalPJ Arends30-Jul-02 0:28 
GeneralRe: CEdit style Pin
Renjith Ramachandran30-Jul-02 0:49
Renjith Ramachandran30-Jul-02 0:49 
GeneralQuestion about auto_ptr Pin
pankajdaga29-Jul-02 23:33
pankajdaga29-Jul-02 23:33 
GeneralRe: Question about auto_ptr Pin
Daniel Lohmann30-Jul-02 2:25
Daniel Lohmann30-Jul-02 2:25 
pankajdaga wrote:
ow is it that I can pass an auto_ptr between functions. Shouldn't the test1 object go out of scope now and hence get destroyed. If the auto_ptr does get passed between scopes, when does it get out of scope and the destructor for Complex is called??

This is because std::auto_ptr maintains an owner flag. Always the last auto_ptr that has been used as L-value is the current owner, all other do not destroy the object.

In your TestPass you use a local variable and return it. At this moment a new instance is created via the copy-constructor and gains ownership. Afterwards the local auto_ptr is destroyed, but does not delete the object because it is not the owner any more.

--

Daniel Lohmann

http://www.losoft.de
GeneralMulti-SDI with MFC Pin
Kirill Kovalenko29-Jul-02 22:56
Kirill Kovalenko29-Jul-02 22:56 
GeneralRe: Multi-SDI with MFC Pin
Alexandru Savescu29-Jul-02 23:29
Alexandru Savescu29-Jul-02 23:29 
GeneralRe: Multi-SDI with MFC Pin
Kirill Kovalenko29-Jul-02 23:38
Kirill Kovalenko29-Jul-02 23:38 
GeneralRe: Multi-SDI with MFC Pin
[James Pullicino]30-Jul-02 2:43
[James Pullicino]30-Jul-02 2:43 
GeneralRe: Multi-SDI with MFC Pin
Kirill Kovalenko30-Jul-02 3:30
Kirill Kovalenko30-Jul-02 3:30 
GeneralRe: Multi-SDI with MFC Pin
Giles30-Jul-02 7:47
Giles30-Jul-02 7:47 
GeneralHELP!!!! ActiveX in Visual C++ Pin
mistika29-Jul-02 22:51
mistika29-Jul-02 22:51 
GeneralRe: HELP!!!! ActiveX in Visual C++ Pin
KingsGambit30-Jul-02 6:29
KingsGambit30-Jul-02 6:29 
QuestionHow to change value of member within object within CArray ? Pin
rsg_dj29-Jul-02 22:46
rsg_dj29-Jul-02 22:46 
Answerarr.GetAt(...).x=20 Pin
Anonymous29-Jul-02 22:54
Anonymous29-Jul-02 22:54 
AnswerRe: How to change value of member within object within CArray ? Pin
Alexandru Savescu29-Jul-02 23:34
Alexandru Savescu29-Jul-02 23:34 
GeneralRe: How to change value of member within object within CArray ? Pin
Raphael Kindt30-Jul-02 0:05
Raphael Kindt30-Jul-02 0:05 
GeneralRe: How to change value of member within object within CArray ? Pin
Alexandru Savescu30-Jul-02 0:31
Alexandru Savescu30-Jul-02 0:31 
GeneralRe: How to change value of member within object within CArray ? Pin
Raphael Kindt30-Jul-02 1:06
Raphael Kindt30-Jul-02 1:06 
AnswerRe: How to change value of member within object within CArray ? Pin
Christian Graus30-Jul-02 2:47
protectorChristian Graus30-Jul-02 2:47 
GeneralStandard Radio Buttons Pin
silverspoon29-Jul-02 22:10
silverspoon29-Jul-02 22:10 
GeneralRe: Standard Radio Buttons Pin
PJ Arends30-Jul-02 0:34
professionalPJ Arends30-Jul-02 0:34 

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.