delete-operator Questions
4
I have a pointer to a class, that have a pointer to a multidimensional array but I can't seem to delete it from memory when I need to or set it to NULL.
#define X 10
#define Y 10
struct TestClass...
Jahnke asked 17/8, 2012 at 16:45
2
Solved
I'm trying to (and have solved) a problem with 16 byte alignment issues with a class that contains SSE optimised members. But what is bugging me is a large portion of the examples I have found onli...
Chaiken asked 25/7, 2012 at 8:41
2
Solved
In C++, if you want to dynamically allocate an array, you can do something like this:
int *p;
p = new int[i]; // i is some number
However, to delete the array, you do...
delete[] p;
Why isn't...
Juncaceous asked 26/6, 2012 at 7:4
8
Solved
I have got some code which uses a lot of pointers pointing to the same address.
Given a equivalent simple example:
int *p = new int(1);
int *q = p;
int *r = q;
delete r; r = NULL; // ok
// delete...
Cyanocobalamin asked 14/10, 2010 at 10:53
3
Solved
int *p=(int * )malloc(sizeof(int));
delete p;
When we allocate memory using malloc then we should release it using free and when we allocate using new in C++ then we should release it using dele...
Bollard asked 1/6, 2012 at 16:38
6
Solved
Possible Duplicates:
C++: Delete this?
Object-Oriented Suicide or delete this;
I'm learning C++ by reading the very good book C++ Primer and I'm learning how C++ deallocates memory by...
Cornwell asked 28/5, 2012 at 10:56
6
When I debugging someone else's code, how could I found when a pointer is deleted?
Gladysglagolitic asked 26/5, 2012 at 11:21
3
Solved
I am looking for a functor that deletes its argument:
template<class T>
struct delete_functor
{
void operator()(T* p)
{
delete p;
}
};
Is there something like this in std, tr1 or boost...
Bullyrag asked 27/4, 2010 at 19:33
1
Solved
Does delete ptr differ from operator delete(ptr) only in this, that delete calls ptr destructor? Or in other words, does delete ptr first call a destructor of ptr and then operator delete(ptr) to f...
Dissert asked 13/5, 2012 at 17:18
4
Solved
I know new and delete are keywords.
int obj = new int;
delete obj;
int* arr = new int[1024];
delete[] arr;
<new> header is a part of C++ standard headers. It has two operators (I am not s...
Phares asked 9/5, 2012 at 9:35
3
Solved
I need a C++ refresher. Why does this gives a memory exception?
pear = new char[1024];
pear = "happy go lucky";
delete [] pear; // exception
Hodson asked 26/4, 2012 at 6:15
10
Solved
I often see legacy code checking for NULL before deleting a pointer, similar to,
if (NULL != pSomeObject)
{
delete pSomeObject;
pSomeObject = NULL;
}
Is there any reason to checking for a NUL...
Brazilein asked 5/3, 2009 at 15:47
2
Solved
Assume I have a structure with two pointers each pointing to an object that has an implemented destructor. Also assume that the head points to a Listnode structure that has a non-NULL value *studen...
Stipulation asked 10/4, 2012 at 0:47
4
Solved
I am here stuck with a question in my C++ book with the following:
"What does the use of new require you to also call delete?"
Maybe you have an answer for that?
Moten asked 29/3, 2012 at 6:36
3
Solved
I mean, if i have some class like:
class A{
int* pi;
};
*A pa;
when i call delete pa, will pi be deleted?
Mariehamn asked 29/2, 2012 at 11:35
9
Solved
From c++ FAQ: http://www.parashift.com/c++-faq-lite/dtors.html#faq-11.9
Remember: delete p does two things: it calls the destructor and it deallocates the memory.
If delete deallocates the mem...
Aciniform asked 3/2, 2012 at 7:43
5
# include <iostream>
int main()
{
using std::cout;
int *p= new int;
*p = 10;
cout<<*p<<"\t"<<p<<"\n";
delete p;
cout<<*p<<"\t"<<p<<"\n";
r...
Womanize asked 31/1, 2012 at 1:33
6
Solved
I am wondering what will hapen if I try to do a delete on a pointer that is already deleted, or may have not been allocated ? I've read two things : first, that delete operator will do some checkin...
Despatch asked 14/12, 2011 at 8:58
5
Solved
I have a basic question regarding the const pointers. I am not allowed to call any non-const member functions using a const pointer. However, I am allowed to do this on a const pointer:
delete p;
...
Sheer asked 16/4, 2009 at 8:18
5
Solved
IFSUPCUTILSize* size = NULL;
CoCreateInstance(CLSID_UTILSize, NULL, CLSCTX_INPROC_SERVER, IID_IFSUPCUTILSize, reinterpret_cast<void**>(&size));
if (size != NULL){
size->Release();
si...
Quintile asked 25/8, 2011 at 19:56
4
Solved
How should I write ISO C++ standard conformant custom new and delete operators?
This is in continuation of Overloading new and delete in the immensely illuminating C++ FAQ, Operator overloading, an...
Cao asked 25/8, 2011 at 16:43
8
Solved
So to understand new/delete better (really to prove to myself with small examples why virtual destructors are needed for interfaces), I want to understand memory leaks, so that I may live in fear o...
Sauter asked 6/8, 2011 at 10:57
4
Solved
I know the free operation in C is to tell the compiler this particular memory block is free for compiler to use for further allocation, but the memory is not released.
What about the delete in C++...
Belindabelisarius asked 25/7, 2011 at 13:23
2
Solved
In c++03 it is pretty clear that deleting a null pointer has no effect. Indeed, it is explicitly stated in §5.3.5/2 that:
In either alternative, if the value of the operand of delete is the null...
Rheinland asked 18/7, 2011 at 10:9
1
Solved
I read the following code for deleting pointer object in the open source project X3C.
//! Delete pointer object.
/*!
\ingroup _GROUP_UTILFUNC
\param p pointer object created using 'new'.
*/
tem...
Oculomotor asked 18/7, 2011 at 4:29
© 2022 - 2024 — McMap. All rights reserved.