Test a;
Test *t = new Test;
a, and all its members, are on the stack.
The object pointed to by t, and all its members, are on the heap.
The pointer t is on the stack.
More Related Contents:
- Why should C++ programmers minimize use of ‘new’?
- What uses are there for “placement new”?
- In what cases do I use malloc and/or new?
- delete vs delete[] operators in C++
- Is it safe to delete a NULL pointer?
- Dynamically allocating an array of objects
- Operator new initializes memory to zero
- Compelling examples of custom C++ allocators?
- C++, Free-Store vs Heap
- Any reason to overload global new and delete?
- How to get memory usage under Windows in C++
- Are memory leaks “undefined behavior” class problem in C++?
- Allocating more memory than there exists using malloc
- How can I get the size of a memory block allocated using malloc()? [duplicate]
- Is it possible to delete a non-new object?
- std::vector and contiguous memory of multidimensional arrays
- Pointer-to-pointer dynamic two-dimensional array
- Can I pass std::string to a DLL?
- Check if a pointer points to allocated memory on the heap
- Reason why not to have a DELETE macro for C++
- Is it safe to realloc memory allocated with new?
- Why, really, deleting an incomplete type is undefined behaviour?
- What do I need to do before deleting elements in a vector of pointers to dynamically allocated objects?
- How to alloc a executable memory buffer?
- How does delete work? [duplicate]
- “Right” way to deallocate an std::vector object
- The difference between delete and delete[] in C++ [duplicate]
- Class members and explicit stack/heap allocation
- Why do we even need the “delete[]” operator?
- Should objects delete themselves in C++?