Click here to Skip to main content
15,895,084 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Can some body help me.... Pin
Maximilien14-Dec-04 14:19
Maximilien14-Dec-04 14:19 
AnswerRe: Can some body help me.... Pin
BRIMID15-Dec-04 1:49
BRIMID15-Dec-04 1:49 
GeneralPrint image with DrawImage in GDI+ Pin
giannibal14-Dec-04 12:36
giannibal14-Dec-04 12:36 
Generalgetting icon Pin
pnpfriend14-Dec-04 11:26
pnpfriend14-Dec-04 11:26 
GeneralRe: getting icon Pin
David Crow15-Dec-04 4:23
David Crow15-Dec-04 4:23 
GeneralReading data from Serial Port. Pin
CNewbie14-Dec-04 10:34
CNewbie14-Dec-04 10:34 
GeneralRe: Reading data from Serial Port. Pin
wwwhb200014-Dec-04 14:00
wwwhb200014-Dec-04 14:00 
GeneralFreeing up memory Pin
poiut14-Dec-04 10:29
poiut14-Dec-04 10:29 
Can someone tell me why this isn't freeing up the memory like it suppose to?

Thanks

#include <afxwin.h>
#include <iostream.h>

class CDeeper : public CObject{
private:
CString *strTemp;
public:
CDeeper():strTemp(new CString){}
~CDeeper(){}
void setStr(CString setTemp){ *strTemp = setTemp; }
void Delete(){ delete strTemp; strTemp = NULL; }
};

class CTest : public CDeeper{
private:
int num;
CObList DeeperList;
CDeeper *pDeeper;
public:
CTest(){}
~CTest(){}
void setStr(int i){
num = i;
pDeeper = new CDeeper;
pDeeper->setStr("Hello");
DeeperList.AddTail(pDeeper);
}

void Delete(){
POSITION pos;
pos = DeeperList.GetHeadPosition();
while(pos){
pDeeper = (CTest *)DeeperList.GetNext(pos);
pDeeper->Delete();
delete pDeeper;
}
DeeperList.RemoveAll();
}
};

int main(){
POSITION pos;
CObList strList;
CTest *pTest;
int i;
for (i=0; i< 50000; i++){
pTest = new CTest;
pTest->setStr(i);
strList.AddTail(pTest);
}
pos = strList.GetHeadPosition();
while(pos){
pTest = (CTest *)strList.GetNext(pos);
pTest->Delete();
delete pTest;
}
strList.RemoveAll();
return 0;
}
GeneralRe: Freeing up memory Pin
David Crow15-Dec-04 2:05
David Crow15-Dec-04 2:05 
GeneralRe: Freeing up memory Pin
poiut15-Dec-04 6:28
poiut15-Dec-04 6:28 
GeneralRe: Freeing up memory Pin
poiut15-Dec-04 6:34
poiut15-Dec-04 6:34 
GeneralMFC File Input and Output problem Pin
Member 158681214-Dec-04 10:25
Member 158681214-Dec-04 10:25 
GeneralCHtmlView + focus Pin
iifisher14-Dec-04 10:21
iifisher14-Dec-04 10:21 
GeneralRegister an Active X Control Pin
jerry1211a14-Dec-04 9:56
jerry1211a14-Dec-04 9:56 
GeneralRe: Register an Active X Control Pin
Graham Bradshaw14-Dec-04 10:42
Graham Bradshaw14-Dec-04 10:42 
Generalproblem with long c++ file Pin
dolph_loe14-Dec-04 9:51
dolph_loe14-Dec-04 9:51 
GeneralRe: problem with long c++ file Pin
Sawatzky14-Dec-04 10:55
Sawatzky14-Dec-04 10:55 
GeneralRe: problem with long c++ file Pin
Todd Smith14-Dec-04 11:19
Todd Smith14-Dec-04 11:19 
Questionhow does dialog catch char input? Pin
LeeeNN14-Dec-04 9:08
LeeeNN14-Dec-04 9:08 
AnswerRe: how does dialog catch char input? Pin
David Crow14-Dec-04 9:47
David Crow14-Dec-04 9:47 
GeneralRe: how does dialog catch char input? Pin
LeeeNN14-Dec-04 10:26
LeeeNN14-Dec-04 10:26 
GeneralRe: how does dialog catch char input? Pin
David Crow15-Dec-04 1:58
David Crow15-Dec-04 1:58 
Generalsubclassing the MFC way Pin
Todd Smith14-Dec-04 8:36
Todd Smith14-Dec-04 8:36 
GeneralRunning a local file Pin
Andre Massada14-Dec-04 8:15
Andre Massada14-Dec-04 8:15 
GeneralRe: Running a local file Pin
David Crow14-Dec-04 8:37
David Crow14-Dec-04 8:37 

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.