Click here to Skip to main content
16,007,610 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Removing Help button from Wizard Pin
Paolo Messina5-Aug-01 5:54
professionalPaolo Messina5-Aug-01 5:54 
GeneralMaintaining Referential Integrity Pin
Reno Tiko4-Aug-01 15:37
Reno Tiko4-Aug-01 15:37 
GeneralUsing CTabCtrl Effectivelty Pin
AJ1234-Aug-01 12:11
AJ1234-Aug-01 12:11 
QuestionWhat's the difference? Pin
4-Aug-01 10:21
suss4-Aug-01 10:21 
AnswerRe: What's the difference? Pin
Chris Losinger4-Aug-01 10:26
professionalChris Losinger4-Aug-01 10:26 
GeneralRe: What's the difference? Pin
4-Aug-01 10:32
suss4-Aug-01 10:32 
GeneralRe: What's the difference? Pin
Christian Graus4-Aug-01 11:39
protectorChristian Graus4-Aug-01 11:39 
GeneralRe: What's the difference? Pin
Ben Burnett4-Aug-01 11:40
Ben Burnett4-Aug-01 11:40 
First off, in the second function you should be using operator delete[], or else your just deleting the first allocated integer -- and thus a memory leak.

void func2() { 
    int * something = new int[20]; 
    /// ... 
    delete [] something; 
}


>>>
In func1 the variable isn't available anymore after the function has quit, in func2 it is available even after the function has quit?
<<<

Almost, since you delete the array in func2 it will no longer exist. But had you not called delete the memory would have persisted even after the function went out of scope.

Doing something like this;

int * func2() { 
    int * something = new int[20]; 
    /// ... 
    return something;
}


Would preserve the allocated memory, even after the function goes out of scope.

Ben Burnett

---------
On the topic of code with no error handling -- It's not poor coding, it's "optimistic" Wink | ;)
GeneralRe: What's the difference? Pin
Christian Graus4-Aug-01 11:43
protectorChristian Graus4-Aug-01 11:43 
GeneralRe: What's the difference? Pin
Ben Burnett4-Aug-01 12:00
Ben Burnett4-Aug-01 12:00 
GeneralRe: Gloabl variabl, reference & pointer. Pin
Masaaki Onishi5-Aug-01 6:27
Masaaki Onishi5-Aug-01 6:27 
GeneralRe: What's the difference? Pin
Joe Woodbury5-Aug-01 9:03
professionalJoe Woodbury5-Aug-01 9:03 
Generallinked list with fast sorting Pin
4-Aug-01 4:17
suss4-Aug-01 4:17 
GeneralRe: linked list with fast sorting Pin
Christian Graus4-Aug-01 11:41
protectorChristian Graus4-Aug-01 11:41 
GeneralRe: linked list with fast sorting Pin
6-Aug-01 0:12
suss6-Aug-01 0:12 
GeneralRe: linked list with fast sorting Pin
Malcolm McMahon6-Aug-01 2:40
Malcolm McMahon6-Aug-01 2:40 
GeneralRe: linked list with fast sorting Pin
6-Aug-01 4:08
suss6-Aug-01 4:08 
GeneralRe: linked list with fast sorting Pin
Malcolm McMahon6-Aug-01 5:09
Malcolm McMahon6-Aug-01 5:09 
GeneralRe: linked list with fast sorting Pin
7-Aug-01 1:09
suss7-Aug-01 1:09 
GeneralThread Client\Serveur Pin
4-Aug-01 4:16
suss4-Aug-01 4:16 
GeneralRe: Thread Client\Serveur Pin
4-Aug-01 4:19
suss4-Aug-01 4:19 
GeneralRe: Thread Client\Serveur Pin
Baafie4-Aug-01 14:29
Baafie4-Aug-01 14:29 
GeneralAutomating Project Creation Pin
Steve Thresher4-Aug-01 1:52
Steve Thresher4-Aug-01 1:52 
GeneralRe: Automating Project Creation Pin
Steve Thresher4-Aug-01 2:45
Steve Thresher4-Aug-01 2:45 
GeneralRe: Automating Project Creation Pin
Steve Thresher4-Aug-01 2:48
Steve Thresher4-Aug-01 2:48 

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.