Hey everyone so here's a new code and it compiles but it won't let me separate the data and add more questions for the user. Please help me and thanks in advance!
I need it to enter 3 elements after list2
header file
#ifndef H_myArray
#define H_myArray
class myArray
{
public:
myArray();
myArray(int, int);
~myArray();
int &operator[](int i);
int fillArray();
void setZero();
int getSize();
int getIndex();
private:
int *location;
int size;
int start;
int end;
};
#endif
cpp file
#include <iostream>
#include "myArray.h"
using namespace std;
//List 1 constructor
int &myArray::operator[](int i)
{
cout << "Enter 5 integers: ";
for (i = 0; i <= 10; i++)
{
cin >> i;
}
{
cout << "After filling list1: " << i << endl;
cout << "List2: " << i << endl;
cout << "Enter 3 elements: ";
cin >> endl;
}
return location[i];
}
myArray::myArray(int index, int arraySize)
{
size = (arraySize - index);
for (int i = index; i < arraySize; i++)
location = new int[size];
start = index;
end = arraySize;
}
myArray::~myArray()
{
delete[]location; //Deletes array
}
void myArray::setZero() //Sets the array equal to zero
{
for (int i = 0; i < size; i++)
{
location[i] = 0;
}
}
int myArray::getSize()
{
return size;
}
int myArray::getIndex()
{
return start;
}
int main()
{
myArray list(0, 5);
myArray myList(2, 13);
myArray yourList(-5, 9);
cout << "List 1: 0 0 0 0 0" << endl;
list[] = 444;
return 0;
}