C++ private member of object is modified when calling constructor again
<p>I've created a class in C++ to deal with arrays of 0s and 1s. In private attributes I have a size, a type and an array of integer for the size specified.</p>

<p>My problem is that the values in the array is being modified every time I call the constructor again. In more detailled, I create a first object with the constructor, then a second one and doing this modifies the first one!</p>

<p>I've tried to play around with pointers, the new operator, const pointers to const object, nothing works! Idependently of the size of array I chose, it's always the third, then the sixth, then the ninth, etc value of the array that is modified to the value of the size.
any suggestion appreciated.</p>

<p>some extracts from my code:</p>

<pre><code>class SArray
{
private:
  int SArray_Size;
  int DType;
  int Table[];
public:
  //complete constructor
  SArray::SArray(const int&amp; tsize, const int&amp; ttype)
  {
    SArray_Size = tsize;
    DType = ttype;
    if (ttype == 0) //random array with integer values between 0 and 1
    {
      for (int i = 0; i &lt; getSize(); i++) 
      {
        Table[i] = rand() % 2;
      }
    }
    if (ttype == 1) //default array with only 1s
    {
      for (int i = 0; i &lt; getSize(); i++)
      {
        Table[i] = 1;
      }
    }
  }

};

int main()
{
  const int NbRes = 15;
  //reset the random number generator
  srand(time(0));
  const SArray test3(NbRes,1);
  (test3).print();
  const SArray test1(NbRes,1);
  (test1).print();
  (test3).print();
  return 0;
}
</code></pre>
