The delete
operator deallocates memory and calls the destructor for a single object created with new
.
The delete []
operator deallocates memory and calls destructors for an array of objects created with new []
.
Using delete
on a pointer returned by new []
or delete []
on a pointer returned by new
results in undefined behavior.
Related Posts:
- Is “delete this” allowed in C++?
- How to deal with bad_alloc in C++?
- Deleting a dynamically allocated 2D array
- Meaning of = delete after function declaration
- What is the array form of ‘delete’?
- What’s the equivalent of new/delete of C++ in C?
- C++ delete vector, objects, free memory
- malloc for struct and pointer in C
- How do malloc() and free() work?
- Deleting an object in C++
- What does ‘corrupted double-linked list’ mean
- How to solve access violation writing location error?
- Calculating Page Table Size
- C++ Array of pointers: delete or delete []?
- Why is this vector iterator not incrementable?
- Different ways to deallocate an array – c++
- Is it still safe to delete nullptr in c++0x?
- C++ — expected primary-expression before ‘ ‘
- Using getline() with file input in C++
- lvalue required as left operand of assignment error when using C++
- g++ ld: symbol(s) not found for architecture x86_64
- Making my own toString() method on c++ struct
- Struct Constructor in C++?
- What is meant with “const” at end of function declaration? [duplicate]
- What’s the C++ version of Java’s ArrayList
- C++ Vector of pointers
- error: lvalue required as unary & operand
- What is use of c_str function In c++
- Is there a decent wait function in C++?
- What does T&& (double ampersand) mean in C++11?
- Segmentation Fault (core dumped) C++
- C++ – No matching member function for call to ‘push_back’
- error: lvalue required as unary & operand
- C/C++ JSON parser
- C++ Parsing input string to variables
- Cannot open include file: ‘stdio.h’ – Visual Studio Community 2017 – C++ Error
- srand(time(0)) and random number generation
- How to convert integer to double implicitly?
- How do I tokenize a string in C++?
- Reverse Contents in Array
- Why would we call cin.clear() and cin.ignore() after reading input?
- Should I learn C before learning C++?
- Comparison with string literal results in unspecified behaviour?
- c++: No instance of overloaded function
- C++ error: Undefined symbols for architecture x86_64
- Visual Studio debugger error: Unable to start program Specified file cannot be found
- Printing the correct number of decimal points with cout
- libstdc++-6.dll not found
- C++ Algorithmically Simple Recursive Palindrome Checker
- vector
::size_type in C++ - Insert object at index of vector c++
- Read whole ASCII file into C++ std::string
- Reading getline from cin into a stringstream (C++)
- How to make an array with a dynamic size? General usage of dynamic arrays (maybe pointers too)?
- C++ int float casting
- Arduino sprintf float not formatting
- Call to implicitly deleted copy constructor in LLVM
- C++ Linked List Node with class
- creating an array of object pointers C++
- What is the preferred way to include error messages in C++?
- How to Convert a C++ String to Uppercase
- C++ Fractions Class
- #pragma once vs include guards?
- Debug vs Release in CMake
- Valgrind complains with “Invalid write of size 8”
- C++ Initializing a Global Array
- How to convert an ASCII char to its ASCII int value?
- Warning: non-static data member initializers only available with -std=c++11 or -std=gnu++11?
- C++ – pointer being freed was not allocated error
- Reference to non-static member function must be called
- Call to non-static member function without an object argument compiler error
- C++ compile time error: expected identifier before numeric constant
- How can I assign an array from an initializer list?
- I get this error: “glibc detected”
- How can I get and use the header file
in my C++ program? - cin.eof() functionality
- Implementing a tree in C++
- Drawing Circle with OpenGL
- Run-Time Check Failure #2 – Stack around the variable ‘foo’ was corrupted
- “vector” was not declared in this scope
- Converting string to ASCII
- got “cannot appear in a constant-expression” when using template
- C++ ostream and ofstream conversions
- C++ discards qualifiers
- What is the source of the data for the ProgramFiles, ProgramW6432Dir, ProgramFilesDir (x86), CommonProgramFiles environment variables?
- C++ : Exception occurred in script: basic_string::_S_construct NULL not valid
- Error: “expected primary-expression before int”
- Dynamic vs static array in c
- C++ Error: Expected a type specifier
- Where to declare/define class scope constants in C++?
- Friend methods error
- Does WPF Work with C++?
- Multiple inputs on one line
- Why do I get: -9223372036854775808
- Return a 2d array from a function
- Linker error: “linker input file unused because linking not done”, undefined reference to a function in that file
- Compiler error C4430: missing type specifier – int assumed [duplicate]
- ‘&’ : illegal operation on bound member function expression [duplicate]
- Multiple definitions of “Main”
- Getting the error floating point exception: 8