title: Error code C6262 consider moving data to heap
body: <p>This code C6262 warning keeps showing up causing problems to the program and I tried searching for possible solutions but I am having a difficult time understanding. I would really appreciate if some could help me with this and if you could point out any bad parts of the code that I could improve.</p>
  <pre><code>#include &lt;iostream&gt;
  #include &lt;cstdlib&gt;
  #include &lt;algorithm&gt;
  using namespace std;
  
  class sorting {
  private:
  int size, elements;
  int arr[5000], x;
  
  
  public:
  void sort() {
      cout &lt;&lt; &quot;Enter number of desired elements for the 1st set&quot; &lt;&lt; &quot;&gt;&quot;; cin &gt;&gt; elements;
      arr[elements];
      half(); cout &lt;&lt; endl;
      bubble();
  
      
      for (int i = 0; i &lt; elements; i++) {
          cout &lt;&lt; arr[i] &lt;&lt; &quot; &quot;;
  
      }
  
      
  
  }
  void half() {
      for (int i = 0; i &lt; elements / 2; i++) {
          arr[i] = i + 1;
      }
      for (int i = elements / 2; i &lt; elements; i++) {
          arr[i] = rand();
      }
      cout &lt;&lt; &quot;This is the elements of the 1st set: &quot;;
      for (int i = 0; i &lt; elements; i++) {
          cout &lt;&lt; arr[i] &lt;&lt; &quot; &quot;;
      }
  }
  void random() {
      for (int i = 0; i &lt; elements; i++) {
          arr[i] = i + 1;
  
      }
  
      random_shuffle(&amp;arr[0], &amp;arr[elements]);
  
      cout &lt;&lt; &quot;This is the elements of the 2nd set: &quot;;
  
      for (int i = 0; i &lt; elements; i++) {
          cout &lt;&lt; arr[i] &lt;&lt; &quot; &quot;;
  
      }
  
  }
  void ascend_descend() {
      int x = elements / 2;
      arr[0] = x;
      for (int i = 0; i &lt; elements / 2; i++) {
          arr[i + 1] = x - 1;
          x--;
      }
      for (int i = elements / 2; i &lt; elements; i++) {
          arr[i] = i + 1;
      }
      cout &lt;&lt; &quot;This is the elements of the 3rd set: &quot;;
      for (int i = 0; i &lt; elements; i++) {
          cout &lt;&lt; arr[i] &lt;&lt; &quot; &quot;;
      }
  
  
  
  };
  void bubble() {
      for (int i = 0; i &lt; elements; i++) {
          int temp;
          for (int j = i + 1; j &lt; elements; i++) {
              if (arr[j] &lt; arr[i]) {
                  temp = arr[i];
                  arr[i] = arr[j];
                  arr[j] = temp;
              }
  
          }
  
      };
  }
    };
  
  int main()
  {   
      sorting sortObject;
  
      sortObject.sort();
      return 0;
  }
  </code></pre>