thank u all for your replies.
problem solved
it was related to a string in the app that was valid
:wave:
Printable View
thank u all for your replies.
problem solved
it was related to a string in the app that was valid
:wave:
Good programming practise would be:Quote:
Originally posted by urika
does EVERYTHING i new i have to delete?
the pointers that are newd are from a dll
long SomePointer;
SomePointer = NULL;
SomePointer = new somearray[111];
...
if(SomePointer != NULL){
delete SomePointer;
}
if you delete and it is NULL the system will crash
That should be:Quote:
Originally posted by Deniz
Good programming practise would be:
long SomePointer;
SomePointer = NULL;
SomePointer = new somearray[111];
...
if(SomePointer != NULL){
delete SomePointer;
}
if you delete and it is NULL the system will crash
Better programming practice would be to not use new[] and delete[] and instead use std::vector.Code:delete [] SomePointer;
Regards,
Paul McKenzie
sorry that is just not true.Quote:
Originally posted by Deniz
if you delete and it is NULL the system will crash
int* p = 0;
delete p;
delete p;
delete p;
perfectly ok
Sorry, my humble apologies, if you havent initialised it and delete it, it can be dangerous. I looked at how I do it and here it is:
if(m_pcPointer != NULL){
delete m_pcPointer;
m_pcPointer = NULL;
}
In fact I set it to NULL just to make sure in case it gets deleted elsewhere..
Hi Deniz.
The point is there is no reason for the check.
if(m_pcPointer != NULL){
delete m_pcPointer;
m_pcPointer = NULL;
}
it is just as good as
delete m_pcPointer;
m_pcPointer = NULL;
I was taught different. But as you say, it is pointless in a well written app.
Well you were taught wrong. It does not matter if the app is
well written or not. Calling delete on the null pointer constant is
perfectly legal by design