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.
#include <iostream>
#include <cstdlib>
#include <algorithm>
using namespace std;
class sorting {
private:
int size, elements;
int arr[5000], x;
public:
void sort() {
cout << "Enter number of desired elements for the 1st set" << ">"; cin >> elements;
arr[elements];
half(); cout << endl;
bubble();
for (int i = 0; i < elements; i++) {
cout << arr[i] << " ";
}
}
void half() {
for (int i = 0; i < elements / 2; i++) {
arr[i] = i + 1;
}
for (int i = elements / 2; i < elements; i++) {
arr[i] = rand();
}
cout << "This is the elements of the 1st set: ";
for (int i = 0; i < elements; i++) {
cout << arr[i] << " ";
}
}
void random() {
for (int i = 0; i < elements; i++) {
arr[i] = i + 1;
}
random_shuffle(&arr[0], &arr[elements]);
cout << "This is the elements of the 2nd set: ";
for (int i = 0; i < elements; i++) {
cout << arr[i] << " ";
}
}
void ascend_descend() {
int x = elements / 2;
arr[0] = x;
for (int i = 0; i < elements / 2; i++) {
arr[i + 1] = x - 1;
x--;
}
for (int i = elements / 2; i < elements; i++) {
arr[i] = i + 1;
}
cout << "This is the elements of the 3rd set: ";
for (int i = 0; i < elements; i++) {
cout << arr[i] << " ";
}
};
void bubble() {
for (int i = 0; i < elements; i++) {
int temp;
for (int j = i + 1; j < elements; i++) {
if (arr[j] < arr[i]) {
temp = arr[i];
arr[i] = arr[j];
arr[j] = temp;
}
}
};
}
};
int main()
{
sorting sortObject;
sortObject.sort();
return 0;
}