Let say I have a hypothetical pointer declared with new like so: int* hypothetical_pointer = new int; and create another hypothetical pointer, with the same value:
This question already has an answer here: W开发者_如何学运维hat is the behavior of "delete" with stack objects? [duplicate]
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:
This question already has answer开发者_开发技巧s here: Closed 12 years ago. Possible Duplicate: Is it OK to use “delete this” to delete the current object?
This is merely for curiosity sake because I have not used new and delete in c++ except for the most basic uses.
This question already has answers here: 开发者_如何学运维Closed 12 years ago. Possible Duplicate:
Say I do something like this for(int i = 0; i < 10; i++) { //create a pointer object using new //use the object
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];
Is it safe to delete a NULL point开发者_运维百科er? And is it a good coding style?delete performs the check anyway, so checking it on your side adds overhead and looks uglier. A very good practice is
For a project I have to implement a bitset class. My code thus far is: Header File #ifndef BITSET_H_ #define BITSET_H_