Sobes.tech
Junior — Senior

Custom dynamic array container (Vector)

livecode

Task condition

It is necessary to write a custom implementation of a Vector container that behaves the same as the standard std::vector. The main operations to implement are:

  • push_back — adding an element to the end with copying;
  • pop_back — removing the last element;
  • emplace_back — constructing a new element in place using perfect forwarding.
# include <iostream>

template<typename T>
class Vector {
public:
    // Implement: push_back, pop_back, emplace_back
};

For each function, ensure proper memory management, array resizing when necessary, and correct handling of objects of any type.