title: Dynamic memory allocation initialisation in C++ class
body: <p>(I'm not posting my code as this is for a project, however I have tried to get help for this issue but have had no luck)</p>
  
  <p>Hi there, I am trying to initialise the size of an array of pointers (<code>char*</code>) which is a private member variable of my class <code>class A</code></p>
  
  <p>I'm using the constructor to set the size by setting an integer variable (also a member variable) which will then be used to create my array of pointers.</p>
  
  <p>I have done this so far:</p>
  
  <pre><code>// Constructor - 'int value' is set to a value
  private:
      int value;
      char ** myArray = new char*[value];
  </code></pre>
  
  <p>So basically I want an array of pointers in which each element can point to a string. I am passing string variables to <code>myArray</code> by using (<code>char*</code>) <code>stringVar.c_str();</code></p>
  
  <p>Although all of this works, I am getting some pretty weird errors when trying to store variables and have even gotten this error:</p>
  
  <blockquote>
    <p>free (): invalid next size (fast)</p>
  </blockquote>
  
  <p>It's weird because even when <code>myArray</code> is of size 4, when I try to access, say, the 3rd element, I get the same error as above.</p>
  
  <p>I am very new to C++ and am very intent on solving these issues. I've had to resort to this forum for help and am looking forward to some ideas from you guys :)</p>