mardi 15 août 2017

Setting all elements of an array of pointers to nullptr in C++

I am just wondering if there is a way of setting an initialized array of pointers to all null values without using a loop?

class Abc{
  //An array of 2000 Product pointers
  Product* product_[2000];
      public:
         Abc();
}

I want to set all pointers to null when the constructor is called:

Abc::Abc(){
    product_ = {};
}

This does not work, product_ must be a modifiable value. Is there an easier way than looping 2000 elements?

Thanks.

Aucun commentaire:

Enregistrer un commentaire