title: Class private data - on stack or heap
body: <p>In the following code:</p>
  
  <pre><code>class Array {
     public:
        int&amp; operator[] (unsigned i) { if (i &gt; 99) error(); return data[i]; }
     private:
        int data[100];
  };
  
  int main()
  {
     Array a;
     a[10] = 42;
     a[12] += a[13];
     ...
  }
  </code></pre>
  
  <p>(Correct me if I'm wrong) The variable a of type Array is on the stack since new was not used to allocate it. The Array class has int data[100], and the operator overload returns reference to particular index in data.</p>
  
  <p>Referring <a href="https://stackoverflow.com/q/4643713/682869">question</a>.</p>
  
  <p>My question is whether int data[100] is on the stack or heap ? I think it shouldn't be the stack, otherwise how can a reference return like the one above still work.</p>
  
  <p>Thanks.</p>