I am looking for some help on some various errors and problems. This is my header file in which I am getting various errors in my for loops saying expected primary expression before } token.
#include <iostream>
using namespace std;
template <class T>
class basicArray
{
public:
basicArray();
basicArray(int arraySize);
T getSize();
T initArray();
T printArray();
T sortArray();
private:
T *data;
int size;
};
//instantiate data as a 16 element array
template <class T>
basicArray<T>::basicArray()
{
T data[16];
}
/*confused if this is right. one argument constructor with parameter that gives the size of the array and stores the value in size. instantiate data as an array of type with size number ofelements. */
template <class T>
basicArray<T>::basicArray(int arraySize )
{
arraySize = size;
data = new T[size];
}
//getsize method return the size of the array
template <class T>
T basicArray<T>::getSize()
{
return size;
}
//initialize the array with random values
template <class T>
T basicArray<T>::initArray()
{
int i;
srand(0);
for(i=0, i<size, i++)
{
a[i] = rand() %100;
}
}
//print method for the array
template <class T>
T basicArray<T>::printArray()
{
int i;
for(i=0, i<size, i++)
{
cout << "Array["<<i<<"]= " << a[i] << endl;
}
}
//sort method for the array
template <class T>
T basicArray<T>::sortArray()
{
int i, j;
int indexMin;
int valueMin;
for(i=0, i<size, i++)
{
indexMin = i;
valueMin = a[i];
for(j=i+1, j<arraySize,j++)
{
if(a[j] < valueMin)
{
indexMin = j;
valueMin = A[j];
}
}
a[indexMin] = A[i];
a[i] = valueMin;
}
}
In my main function I need to call initArray, then printArray, then sortArray, and printArray to have an output looking like Array[0] = 53. A little confused with this.