Click here to Skip to main content
15,923,689 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionPassing a CList (or reference to a CList) as a function parameter?? Pin
27-Sep-01 5:34
suss27-Sep-01 5:34 
AnswerRe: Passing a CList (or reference to a CList) as a function parameter?? Pin
Michael Dunn27-Sep-01 8:16
sitebuilderMichael Dunn27-Sep-01 8:16 
GeneralWebBrowser Control & 3D Borders Pin
27-Sep-01 4:43
suss27-Sep-01 4:43 
GeneralRef Counting Pin
User 988527-Sep-01 4:36
User 988527-Sep-01 4:36 
GeneralRe: Ref Counting Pin
Not Active27-Sep-01 6:55
mentorNot Active27-Sep-01 6:55 
GeneralRe: Ref Counting Pin
Joaquín M López Muñoz27-Sep-01 8:28
Joaquín M López Muñoz27-Sep-01 8:28 
GeneralRe: Ref Counting Pin
User 988527-Sep-01 8:52
User 988527-Sep-01 8:52 
GeneralRe: Ref Counting Pin
Joaquín M López Muñoz27-Sep-01 9:28
Joaquín M López Muñoz27-Sep-01 9:28 
Is there something wrong in my understanding of the situation?

No, your understanding of the situation is absolutely correct, and the object will get deleted when MyFunc returns. CPtrList is a beast every reasonable programmer should try to avoid, because it forces you to abandon type information when storing things in it and reinferring it later thru an explicit cast. Things are no better with CTypedPtrList, as the poor patch it proposes to bring type information back does not permit you to deal with smart pointers.

If you can make the switch, I recommend you enter the wondrous land of STL and substitute list<CPtr<CMyclass> > for your former MFC lists everywhere. Additionally, you might want to reconsider having defined operator CMyClass * (), as it paves the way to errors resulting from inadvertently casting your smart pointers away thus loosing track of the right ref count (as in your example). It'd be better to have an explicit method for casting like T * get() so the programmer is aware of entering a risk zone when she/he uses it.

Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
QuestionHow to change a item's parent of a tree control? Pin
27-Sep-01 3:52
suss27-Sep-01 3:52 
AnswerRe: How to change a item's parent of a tree control? Pin
Derek Lakin27-Sep-01 4:26
Derek Lakin27-Sep-01 4:26 
GeneralRe: How to change a item's parent of a tree control? Pin
27-Sep-01 15:54
suss27-Sep-01 15:54 
GeneralRe: How to change a item's parent of a tree control? Pin
Derek Lakin27-Sep-01 22:11
Derek Lakin27-Sep-01 22:11 
GeneralContol Bars Pin
27-Sep-01 3:43
suss27-Sep-01 3:43 
QuestionWhat the hell...? Pin
27-Sep-01 3:30
suss27-Sep-01 3:30 
AnswerRe: What the hell...? Pin
Rashid Thadha27-Sep-01 3:37
Rashid Thadha27-Sep-01 3:37 
GeneralThanks!!! Pin
27-Sep-01 3:46
suss27-Sep-01 3:46 
AnswerRe: What the hell...? Pin
Aaron Schaefer27-Sep-01 3:46
Aaron Schaefer27-Sep-01 3:46 
GeneralHot Keys Of Menu In A Dialog Box Pin
Ahmad9927-Sep-01 2:48
Ahmad9927-Sep-01 2:48 
GeneralRe: Hot Keys Of Menu In A Dialog Box Pin
Tomasz Sowinski27-Sep-01 2:54
Tomasz Sowinski27-Sep-01 2:54 
GeneralRe: Hot Keys Of Menu In A Dialog Box Pin
Ahmad9927-Sep-01 3:29
Ahmad9927-Sep-01 3:29 
GeneralRe: Hot Keys Of Menu In A Dialog Box Pin
Ahmad9927-Sep-01 3:29
Ahmad9927-Sep-01 3:29 
GeneralThanks Pin
Ahmad9927-Sep-01 4:27
Ahmad9927-Sep-01 4:27 
GeneralContent of Stl-Container in Debug-Mode Pin
Olivier Heidemann27-Sep-01 2:35
Olivier Heidemann27-Sep-01 2:35 
QuestionVideo Capture Resolution Change? Pin
jwrich0127-Sep-01 2:29
jwrich0127-Sep-01 2:29 
Generalbitmap from imglist Pin
Noman Nadeem27-Sep-01 1:39
Noman Nadeem27-Sep-01 1:39 

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.