Click here to Skip to main content
15,909,440 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
Generalnew delete question Pin
alex.barylski28-Jan-02 20:11
alex.barylski28-Jan-02 20:11 
GeneralRe: new delete question Pin
Fredrik Skog28-Jan-02 20:32
Fredrik Skog28-Jan-02 20:32 
GeneralRe: new delete question Pin
alex.barylski28-Jan-02 20:47
alex.barylski28-Jan-02 20:47 
GeneralRe: new delete question Pin
Joaquín M López Muñoz28-Jan-02 21:18
Joaquín M López Muñoz28-Jan-02 21:18 
GeneralRe: new delete question Pin
alex.barylski28-Jan-02 22:10
alex.barylski28-Jan-02 22:10 
GeneralRe: new delete question Pin
Joaquín M López Muñoz28-Jan-02 22:26
Joaquín M López Muñoz28-Jan-02 22:26 
GeneralRe: new delete question Pin
alex.barylski28-Jan-02 22:51
alex.barylski28-Jan-02 22:51 
GeneralRe: new delete question Pin
Roger Allen29-Jan-02 1:26
Roger Allen29-Jan-02 1:26 
You can still use new and delete. In your SetSize function you need to delete the memory first beofre allocating the new one, or if you need the old values still, copy it across:

MyClass::MyClass()
{
m_pData = NULL ;
}

MyClass::~MyClass()
{
delete []m_pData ;
}

void MyClass::SetSize(int new_size)
{
ASSERT(new_size >= 1) ;
delete []m_pdata ;  // OK to delete NULL pointer
m_pData = NULL ;
m_pData = new char[new_size] ;
}



Roger Allen
Sonork 100.10016

If I'm not breathing, I'm either dead or holding my breath.
GeneralRe: new delete question Pin
alex.barylski29-Jan-02 10:14
alex.barylski29-Jan-02 10:14 
Generalcolor palette Pin
Steve L.28-Jan-02 18:02
Steve L.28-Jan-02 18:02 
GeneralRe: color palette Pin
Derek Waters28-Jan-02 18:05
Derek Waters28-Jan-02 18:05 
GeneralRe: color palette Pin
Steve L.29-Jan-02 6:12
Steve L.29-Jan-02 6:12 
GeneralCRichEditCtrl and Dialog App Pin
Matt Newman28-Jan-02 15:18
Matt Newman28-Jan-02 15:18 
GeneralRe: CRichEditCtrl and Dialog App Pin
Matt Gullett28-Jan-02 15:43
Matt Gullett28-Jan-02 15:43 
GeneralRe: CRichEditCtrl and Dialog App Pin
Matt Newman28-Jan-02 16:28
Matt Newman28-Jan-02 16:28 
GeneralRe: CRichEditCtrl and Dialog App Pin
Mazdak28-Jan-02 22:47
Mazdak28-Jan-02 22:47 
GeneralRe: CRichEditCtrl and Dialog App Pin
Mazdak28-Jan-02 22:52
Mazdak28-Jan-02 22:52 
GeneralRe: CRichEditCtrl and Dialog App Pin
Braulio Dez29-Jan-02 0:24
Braulio Dez29-Jan-02 0:24 
GeneralRe: CRichEditCtrl and Dialog App Pin
Mazdak29-Jan-02 18:22
Mazdak29-Jan-02 18:22 
GeneralParsing IP Addresses and Domain Names Pin
Jean Louis28-Jan-02 15:15
Jean Louis28-Jan-02 15:15 
GeneralRe: Parsing IP Addresses and Domain Names Pin
markkuk28-Jan-02 19:41
markkuk28-Jan-02 19:41 
GeneralRe: Parsing IP Addresses and Domain Names Pin
Jean Louis29-Jan-02 6:50
Jean Louis29-Jan-02 6:50 
Questionimplement button on docking Dialogbar? Pin
28-Jan-02 13:45
suss28-Jan-02 13:45 
AnswerRe: implement button on docking Dialogbar? Pin
Fredrik Skog28-Jan-02 20:16
Fredrik Skog28-Jan-02 20:16 
GeneralThanks Pin
29-Jan-02 3:23
suss29-Jan-02 3:23 

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.