There is no way of doing this – and if you need to do it, there is something wrong with your design. There is a discussion of why you can’t do this in More Effective C++.
More Related Contents:
- Avoid memory leaks in C++ Pointers [closed]
- Is it safe to delete a NULL pointer?
- Dynamically allocating an array of objects
- Determine the size of a C++ array programmatically?
- Pointer-to-pointer dynamic two-dimensional array
- What happens when you deallocate a pointer twice or more in C++?
- Check if a pointer points to allocated memory on the heap
- Reason why not to have a DELETE macro for C++
- What do I need to do before deleting elements in a vector of pointers to dynamically allocated objects?
- What happen to pointers when vectors need more memory and realocate memory?
- Dangling Pointers after Destructor is called
- Weird behavior with OOP and string pointers
- Why is my program slow when looping over exactly 8192 elements?
- How to avoid memory leaks when using a vector of pointers to dynamically allocated objects in C++?
- difference between a pointer and reference parameter?
- Pointers in c++ after delete
- Returning a pointer of a local variable C++
- Can I use if (pointer) instead of if (pointer != NULL)?
- Is storing an invalid pointer automatically undefined behavior?
- Why are NULL pointers defined differently in C and C++?
- Function pointer vs Function reference
- What happens to the pointer itself after delete? [duplicate]
- How to deal with bad_alloc in C++?
- dynamically allocated memory after program termination
- Why does this program crash: passing of std::string between DLLs
- Is global memory initialized in C++?
- C++: difference between ampersand “&” and asterisk “*” in function/method declaration?
- If a 32-bit integer overflows, can we use a 40-bit structure instead of a 64-bit long one?
- difference between pointer to an array and pointer to the first element of an array
- C++ delete does not free all memory (Windows)