I need a two dimensional array filled with instances of different derived types my code looks like this:
std::array<std::array<std::shared_ptr<Base>, 1>, 1> b;
b[1][1] = std::shared_ptr<Base>(new Derived(x, y));
The code compiles but there is some form of memory leak in std::__shared_weak_count::__release_shared() during the execution of the second line.
My question is: How can I properly create a two dimensional array of derived classes?
b[1]is out of boundsT a[1][1]; a[1][1] = v;is going out of bounds, your code is going out of bounds as well.std::make_shared<Derived>(x, y)instead ofstd::shared_ptr<Base>(new Derived(x, y))