Click here to Skip to main content
15,902,299 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralWeird pointer behavior Pin
K. Shaffer14-Feb-05 6:32
K. Shaffer14-Feb-05 6:32 
GeneralRe: Weird pointer behavior Pin
Michael Dunn14-Feb-05 7:06
sitebuilderMichael Dunn14-Feb-05 7:06 
GeneralRe: Weird pointer behavior Pin
Maximilien14-Feb-05 7:06
Maximilien14-Feb-05 7:06 
GeneralRe: Weird pointer behavior Pin
rocky_pulley14-Feb-05 7:06
rocky_pulley14-Feb-05 7:06 
GeneralRe: Weird pointer behavior Pin
K. Shaffer14-Feb-05 7:50
K. Shaffer14-Feb-05 7:50 
GeneralRe: Weird pointer behavior Pin
K. Shaffer14-Feb-05 7:55
K. Shaffer14-Feb-05 7:55 
GeneralRe: Weird pointer behavior Pin
Maximilien14-Feb-05 8:38
Maximilien14-Feb-05 8:38 
GeneralRe: Weird pointer behavior Pin
TFrancis14-Feb-05 8:52
TFrancis14-Feb-05 8:52 
If, GetAddressOfApproachSomePlaceElse() calls new, then yes, this would be a memory leak. If in your function you want to change what object a pointer points to (not the object itself, but what object it points to), then one technique is to pass it a pointer to a pointer.

CApproach* pApproach = NULL;
GetNextApproach(&pApproach)

void GetNextApproach(CApproach** ppApproach)
{
*ppApproach = GetAddressOfApproachSomePlaceElse();
}

If you simply pass it a pointer, then it makes a copy of the pointer (not a copy of the object, but a copy of the pointer to the object). Any changes you make to the pointer (not the object, but the pointer to the object) will not be kept when the function returns, they are thrown away with the copy of the pointer.

Hope this helps,

Tim
GeneralRe: Weird pointer behavior Pin
Christian Graus14-Feb-05 15:02
protectorChristian Graus14-Feb-05 15:02 
GeneralSplitting with the existance of COutlook2Ctrl Pin
Mohammad Tarik14-Feb-05 6:10
Mohammad Tarik14-Feb-05 6:10 
GeneralRe: Splitting with the existance of COutlook2Ctrl Pin
rocky_pulley14-Feb-05 7:35
rocky_pulley14-Feb-05 7:35 
GeneralRe: Splitting with the existance of COutlook2Ctrl Pin
Mohammad Tarik14-Feb-05 12:18
Mohammad Tarik14-Feb-05 12:18 
Generali want to create my own takbar... Pin
14-Feb-05 5:33
suss14-Feb-05 5:33 
GeneralRe: i want to create my own takbar... Pin
rocky_pulley14-Feb-05 7:36
rocky_pulley14-Feb-05 7:36 
GeneralRe: i want to create my own taskbar... Pin
jaisri_g15-Feb-05 4:05
jaisri_g15-Feb-05 4:05 
GeneralSetting up multiple-port TCP/IP printers with TCPMON Xcv Commands Pin
TweakIt14-Feb-05 5:31
TweakIt14-Feb-05 5:31 
QuestionHow can I get ride of the 'X' that closes an application. Pin
mcgahanfl14-Feb-05 4:45
mcgahanfl14-Feb-05 4:45 
AnswerRe: How can I get ride of the 'X' that closes an application. Pin
John M. Drescher14-Feb-05 5:33
John M. Drescher14-Feb-05 5:33 
AnswerRe: How can I get ride of the 'X' that closes an application. Pin
Kippesoep14-Feb-05 6:36
Kippesoep14-Feb-05 6:36 
GeneralResource DLL Pin
Franz Klein14-Feb-05 4:13
Franz Klein14-Feb-05 4:13 
GeneralRe: Resource DLL Pin
rocky_pulley14-Feb-05 4:21
rocky_pulley14-Feb-05 4:21 
GeneralRe: Resource DLL Pin
Franz Klein14-Feb-05 4:31
Franz Klein14-Feb-05 4:31 
GeneralRe: Resource DLL Pin
Shog914-Feb-05 7:57
sitebuilderShog914-Feb-05 7:57 
GeneralApp doesn't shut down propperly Pin
IGeorgeI14-Feb-05 2:45
IGeorgeI14-Feb-05 2:45 
GeneralRe: App doesn't shut down propperly Pin
Blake Miller14-Feb-05 5:29
Blake Miller14-Feb-05 5:29 

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.