title: Initializing array inside class gives std::bad_alloc error, but outside doesn't?
body: <p>I have a program with two classes (I'll call them Master and Slave), with Slave inheriting from Master. In Slave, I defined a struct, and an array of possible values of this struct type. Slave is then instantiated with the index of the array whose values I want to fill variables from the Master class.</p>
  
  <p>Like so:</p>
  
  <pre><code>class Master
  {
  public:
      std::string _a;
      char _b;
      int _c;
      int _d;
      int _e;
  
      Master(std::string a, char b, int c, int d, int e)
          : _a {a}, _b {b}, _c {c}, _d {d}, _e {e} {}
  };
  
  class Slave : public Master
  {
  public:
      struct SlaveStruct
      {
          std::string a;
          char b;
          int c;
          int d;
          int e;
      };
  
      const SlaveStruct slaveArray[3]
      {
          {"name_a", 'A', 1, 2, 3},
          {"name_b", 'B', 4, 5, 6},
          {"name_c", 'C', 7, 8, 9}
      };
  
      Slave(int index) : Master {slaveArray[index].a, slaveArray[index].b, 
          slaveArray[index].c, slaveArray[index].d, slaveArray[index].e} {}
  };
  </code></pre>
  
  <p>This, however, gives off a std::bad_alloc error when I try to instantiate it. Messing around, I found it works perfectly fine however if I just declare the array inside the class, and initialize it outside, as such:</p>
  
  <pre><code>class Slave : public Master
  {
      //(...)
  
      static SlaveStruct slaveArray[3];
  
      //(...)
  };
  
  Slave::SlaveStruct Slave::slaveArray[3]
  {
      {"name_a", 'A', 1, 2, 3},
      {"name_b", 'B', 4, 5, 6},
      {"name_c", 'C', 7, 8, 9}
  };
  </code></pre>
  
  <p>Why is that, however? This array is 144 bytes in size, it should barely make a dent in the stack, and I'm only instantiating the class once. Tried debugging it, but after stepping in the Slave constructor it goes into a deep rabbit-hole of C++ native functions which I can't make sense of, and soon the bad_alloc error is thrown.</p>
  
  <p><strong>UPDATE</strong>: As per requested in comments, class is instantiated as such:</p>
  
  <pre><code>int main()
  {
      Slave slave {1}; // For example, any index will throw the same error.
  }
  </code></pre>
  
  <p>Platforms: Windows 10, MSVC 2017.</p>