I'm a college student, and a bit lost on part of a homework assignment.
The premise is we have a .h file containing all the function declarations and are commented with what they need to do, and we create a .hpp file that fits the defined criteria to be tested with a .cpp driver.
I'm kind of lost on how to define the operator[] functions, however, and would appreciate any help.
template <typename T>
class ArrayList
{
private:
int m_size; // current number of elements
int m_max; // maximum capacity of array m_data
T* m_data; // array to store the elements
T m_errobj; // object to return in case of error
public:
// Purpose: return a read-and-write reference to the element at
// the specified position
// Parameters: i is 0-based index into the ArrayList
// Returns: the element at position i in the ArrayList
T& operator[](int i);
// Purpose: return a read-only reference to the element at
// the specified position
// Parameters: i is 0-based index into the ArrayList
// Returns: the element at position i in the ArrayList
const T& operator[](int i) const;
And I'm just lost on what I need to put in the definition.