How do I initialize a dynamically allocated array within a class constructor
<p>we are supposed to assign an empty string into each index  and later replace 
that with a value in the function addB().
I am quite new to this so I am having a lot of trouble.</p>

<pre><code>class A //in a.h

{

  private:

    B * b;

    int maxNumberOfItems;

    //...

  public:

  A();

  ~A();

 void addB(const B &amp; something);

};

//in a.cpp

 A::A()

  {

    maxNumberOfItems=10;
    for(int i=0;i&lt;maxNumberOfItems;i++)
    {
       b[i]="";//has to be an empty string, I am getting a segmentation fault
    }

  }

  A::~A(){/*...*/}

  //...

//in b.h

class B
{

 private:

      string name;

      int price;

  public:

      void setName(string);

      string getName();

      void setPrice();

      int getPrice(int);

      B &amp; operator=(string &amp;);

};

//in b.cpp

B &amp; B::operator=(string &amp; a){name = a;price = 0; return *this;}
//...
</code></pre>

<p>this is only a snippet of the program showing my issue</p>