delete-operator Questions

3

Solved

If I have 3 pointers to double : rdf1 = new double [n]; rdf2 = new double [n]; rdf3 = new double [n]; I want to delete them with a single delete statement. something like : delete [] rdf1,rdf...
Laticialaticiferous asked 14/7, 2011 at 14:22

6

Solved

Possible Duplicate: delete[] supplied a modified new-ed pointer. Undefined Behaviour? Let's say I've allocated a handful of characters using new char[number]. Will it be possible to ...
Heater asked 1/7, 2011 at 3:16

3

I'm writing a debug versions of global delete/new operator to detect memory leaks, double deletes and delete on unallocated memory. As far as "new" operator is concerned, I overrode the global new...
Krill asked 13/6, 2011 at 5:58

8

Solved

I have been researching, and nothing relevant has come up, so I came here. I am trying to avoid memory leaks, so I am wondering: Say I have class MyClass with member ints a and b, and an int arra...
Lead asked 6/6, 2011 at 18:38

7

Solved

int* Array; Array = new int[10]; delete[] Array; The delete knows the count of allocated memory. I Googled that it stores it in memory, but it's compiler dependent. Is there anyway to use get t...
Counseloratlaw asked 4/6, 2011 at 22:15

6

Solved

I have a char**, basically an array of strings, that I need to delete. What is the correct way of doing this to ensure all pointers are cleared up?
Pampero asked 13/5, 2011 at 9:10

4

Solved

In my C++ program, I create objects in one function using new. These objects are inserted into a set. When I want to remove objects from the set, I use an iterator in a for-loop. When I remove the ...
Selfinduction asked 30/4, 2011 at 1:49

5

I've written a program that allocates a new object of the class T like this: T* obj = new T(tid); where tid is an int Somewhere else in my code, I'm trying to release the object I've allocated...
Buster asked 22/3, 2011 at 16:16

2

Solved

Consider following code: typedef SomeType type_t[2]; SomeType * arr1 = new type_t; //new or new[] ??? type_t * arr2 = new type_t[3]; //new or new[] ??? According standard which version of new wi...
Seeseebeck asked 20/3, 2011 at 14:13

3

Solved

I got the following test code from http://support.microsoft.com/kb/131322: const int * pi = new int(1000); const char * pch = new char(65); void main(void) { delete pi ;// Error C2710:cannot de...
Chromomere asked 28/1, 2011 at 9:45

9

Solved

Possible Duplicate: delete vs delete[] operators in C++ I've written a class that contains two pointers, one is char* color_ and one in vertexesset* vertex_ where vertexesset is a cla...
Welldressed asked 12/1, 2011 at 15:50

3

Solved

Possible Duplicates: Is it OK to use "delete this" to delete the current object? Should objects delete themselves in C++? I just came across this question on programmers.st...
Bordure asked 15/12, 2010 at 11:54

4

I'm dang certain that this code ought to be illegal, as it clearly won't work, but it seems to be allowed by the C++0x FCD. class X { /* ... */}; void* raw = malloc(sizeof (X)); X* p = new (raw) X...
Woll asked 11/12, 2010 at 18:24

3

Solved

This one made me think: class X; void foo(X* p) { delete p; } How can we possibly delete p if we do not even know whether X has visible destructor? g++ 4.5.1 gives three warnings: warning: p...

6

Solved

Possible Duplicate: Is it OK to use “delete this” to delete the current object? I just saw some code where they have done delete this; in a class function, I know that thi...
Dictator asked 29/11, 2010 at 16:23

6

Solved

If a Base class does not have a virtual destructor (in order to avoid the vtable entry for instance) and the Derived class has only basic attributes, does it free all the memory allocated by new, w...
Linzy asked 27/11, 2010 at 21:42

4

Solved

Possible Duplicate: What is the difference between delete and delete[]? When I was taught C++, this was a long time ago. I was told to never use delete but delete[] as performing delete[] ...
Jerrybuilt asked 23/11, 2010 at 11:34

5

Solved

I have this in my code: double** desc = new double* [size_out]; for (int i = 0; i < size_out; i++) desc[i] = new double [size_in]; How do I delete this desc? Should I do: delete [] desc; ...
Venereal asked 16/11, 2010 at 12:12

10

Solved

Consider this program: int main() { struct test { test() { cout << "Hello\n"; } ~test() { cout << "Goodbye\n"; } void Speak() { cout << "I say!\n"; } }; test* MyTe...
Cuyp asked 21/10, 2010 at 17:2

3

Solved

The following code compiled with MSVC9.0 runs and outputs Destructor four times, which is logical. #include <iostream> class SomeClass { public: void CommitSuicide() { delete this; } vo...
Calamine asked 18/10, 2010 at 13:29

11

Solved

This came up as one of the code review comments. Is it a good idea to check for NULL before calling delete for any object? I do understand delete operator checks for NULL internally and is redun...
Idiom asked 29/9, 2010 at 11:43

1

Solved

I always thought... overriding means reimplementing a function (same signature) in a base class whereas overloading means implementing a function with same name but different signature ... and ...
Stockbroker asked 18/9, 2010 at 17:55

5

Solved

Should we delete before or after erase. My understanding is both are OK. Is it correct? In addition, is there any case we won't want to delete the element while erasing it? I believe there must b...
Luxurious asked 17/9, 2010 at 6:24

6

How can I free up memory in a pointer vector? Here's the code: class A { private: int x,y,z; public: A(param1, param2, param3) { x=param1; y=param2; z=param3; } ~A() { //prompts an ale...
Fonz asked 14/9, 2010 at 18:0

4

Solved

Why is there a delete[]? From my understanding its to behave differently for arrays. However, why does it really exist? There's only free in C and no free_array. Also in syntax the only difference ...
Cohabit asked 12/9, 2010 at 9:26

© 2022 - 2024 — McMap. All rights reserved.