No, the Derived
objects will be sliced: all additional members will be discarded.
Instead of raw pointers, use std::vector<std::unique_ptr<Base> >
.
More Related Contents:
- Store derived class objects in base class variables
- Vectors and polymorphism in C++
- Vector that can have 3 different data types C++
- Array of vectors
- How do I print out the contents of a vector?
- Are std::vector elements guaranteed to be contiguous?
- How do I sort a std::vector by the values of a different std::vector?
- Is it safe to assume that STL vector storage is always contiguous?
- dynamical two dimension array according to input
- Efficient way of reading a file into an std::vector?
- Looking for C++ STL-like vector class but using stack storage
- How to use an iterator?
- How to initialize std::vector from C-style array?
- What is the best way to concatenate two vectors?
- Overriding a Base’s Overloaded Function in C++ [duplicate]
- What does the standard say about how calling clear on a vector changes the capacity?
- Iterating C++ vector from the end to the beginning
- How can I store objects of differing types in a C++ container?
- Moving elements from std::vector to another one
- Performance issue for vector::size() in a loop in C++
- STL vector and thread-safety
- c++ Vector, what happens whenever it expands/reallocate on stack?
- How to pass a vector of strings to execv
- std::vector to string with custom delimiter
- Vector.erase(Iterator) causes bad memory access
- Erasing vector::end from vector
- std::vector resize downward
- allocating vectors (or vectors of vectors) dynamically
- Why don’t std::vector’s elements need a default constructor?
- C++ template function compiles in header but not implementation