Dynamically allocating an array of objects

前端 未结 7 1595
挽巷
挽巷 2020-11-22 13:05

I have a class that contains a dynamically allocated array, say

class A
{
    int* myArray;
    A()
    {
        myArray = 0;
    }
    A(int size)
    {
           


        
相关标签:
7条回答
  • 2020-11-22 13:40

    I'd recommend using std::vector: something like

    typedef std::vector<int> A;
    typedef std::vector<A> AS;
    

    There's nothing wrong with the slight overkill of STL, and you'll be able to spend more time implementing the specific features of your app instead of reinventing the bicycle.

    0 讨论(0)
提交回复
热议问题