My functions begin() and end() both work and would return something similar to front() and back(), however I understand I would return a reference to these values with front() and back(). Currently I have
data is defined in private area as:
int * data;
my functions are as follows
int& front() const
{
return data;
}
int& back() const
{
return data + my_size;
}
The errors I am getting are:
IntVector.cpp: In member function ‘int& IntVector::front() const’:
IntVector.cpp:33:9: error: invalid initialization of reference of type ‘int&’ from expression of type ‘int* const’
IntVector.cpp: In member function ‘int& IntVector::back() const’:
IntVector.cpp:38:14: error: invalid initialization of non-const reference of type ‘int&’ from an rvalue of type ‘int*’