Click here to Skip to main content
15,912,897 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralLoad picture data Pin
RonnyS29-Jun-04 4:36
RonnyS29-Jun-04 4:36 
GeneralRe: Load picture data Pin
Johan Rosengren29-Jun-04 20:32
Johan Rosengren29-Jun-04 20:32 
GeneralCreateProcessWithLogonW Pin
A T I F29-Jun-04 4:11
A T I F29-Jun-04 4:11 
GeneralRe: CreateProcessWithLogonW Pin
valikac29-Jun-04 6:31
valikac29-Jun-04 6:31 
GeneralRe: CreateProcessWithLogonW Pin
A T I F29-Jun-04 21:53
A T I F29-Jun-04 21:53 
GeneralRe: CreateProcessWithLogonW Pin
darkbyte30-Jun-04 14:26
darkbyte30-Jun-04 14:26 
GeneralRe: CreateProcessWithLogonW Pin
A T I F30-Jun-04 21:08
A T I F30-Jun-04 21:08 
QuestionHow to delete *ptr correctly? Pin
uus9929-Jun-04 4:03
uus9929-Jun-04 4:03 
I made a very simple class, and when the default destructor is called, i get a debug assertion failure. (i'm using VC++ SP5)

if i call a function like this

void Testfunction()
{
uImage test;
test.Create(100);
}

the function exits properly, with the default destructor deleting the arrays successfully, however,if i call a function like this, that is without allocating the arrays,

void Testfunction()
{
uImage test;
}

The function exits with a Debug Assertion Failure, _CrtIsValidHeapPointer

What i'm confused is that, i'm trying to do cleanup in the destructor by deleting all the dynamic arrays. Although i havent created the arrays, there should be no problem coz i checked whether the pointers are NULL or not (when performing delete). So, why is there a debug assertion?




My class header is

#ifndef UIMAGE_H
#define UIMAGE_H

class uImage
{
private:
int *R;
int *G;
int *B;

public:
uImage();
~uImage();
void Create(int x);
};

#endif

My Class is

#include "StdAfx.h"
#include "uImage.h"


uImage::uImage()
{

}

uImage::~uImage()
{
if(R!=NULL) delete R;
if(G!=NULL) delete G;
if(B!=NULL) delete B;
}

void uImage::Create(int x)
{
R=new int[x];
G=new int[x];
B=new int[x];
}


AnswerRe: How to delete *ptr correctly? Pin
David Crow29-Jun-04 4:24
David Crow29-Jun-04 4:24 
GeneralRe: How to delete *ptr correctly? Pin
uus9929-Jun-04 4:26
uus9929-Jun-04 4:26 
AnswerRe: How to delete *ptr correctly? Pin
Antony M Kancidrowski29-Jun-04 4:33
Antony M Kancidrowski29-Jun-04 4:33 
GeneralRe: How to delete *ptr correctly? Pin
uus9929-Jun-04 4:48
uus9929-Jun-04 4:48 
GeneralRe: How to delete *ptr correctly? Pin
Jeremy Falcon29-Jun-04 6:37
professionalJeremy Falcon29-Jun-04 6:37 
GeneralRe: How to delete *ptr correctly? Pin
Henry miller29-Jun-04 7:17
Henry miller29-Jun-04 7:17 
GeneralRe: How to delete *ptr correctly? Pin
digwizfox29-Jun-04 9:48
digwizfox29-Jun-04 9:48 
GeneralChange radio button group VC++ 6.0 Pin
WerFoog29-Jun-04 3:54
WerFoog29-Jun-04 3:54 
GeneralRe: Change radio button group VC++ 6.0 Pin
rrrado29-Jun-04 4:14
rrrado29-Jun-04 4:14 
GeneralRe: Change radio button group VC++ 6.0 Pin
Blake Miller29-Jun-04 4:15
Blake Miller29-Jun-04 4:15 
GeneralRe: Change radio button group VC++ 6.0 Pin
#realJSOP29-Jun-04 9:17
professional#realJSOP29-Jun-04 9:17 
QuestionAnother way to kill process other than terminate?? Pin
Anonymous29-Jun-04 2:09
Anonymous29-Jun-04 2:09 
AnswerRe: Another way to kill process other than terminate?? Pin
rrrado29-Jun-04 3:49
rrrado29-Jun-04 3:49 
AnswerRe: Another way to kill process other than terminate?? Pin
palbano29-Jun-04 4:29
palbano29-Jun-04 4:29 
QuestionHow to send a signal to another process??? Pin
Anonymous29-Jun-04 2:01
Anonymous29-Jun-04 2:01 
AnswerRe: How to send a signal to another process??? Pin
RadioShark29-Jun-04 2:10
RadioShark29-Jun-04 2:10 
GeneralRe: How to send a signal to another process??? Pin
A T I F29-Jun-04 2:49
A T I F29-Jun-04 2:49 

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.