So I'm supposed to write a function in class called ArrayList. Two of the functions have to deal with finding the first element of the container. One is just a constant version of the other. The protected members of the class are:
protected:
int *m_list; ///< Pointer to dynamic array.
std::size_t m_capacity; ///< Physical size of dynamic array.
std::size_t m_size; ///< Number of array elements in use.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
/// @brief Returns a reference to the first element in the container.
/// Calling front on an empty container is undefined.
/// @return Reference to the first element.
int& front() { return *begin(); }
constint& front() const { return *begin(); }
int& ArrayList::operator[](std::size_t pos)
{
return front();
}
constint& ArrayList::operator[](std::size_t pos) const
{
return front();
}
This is worse than usual lol, when I usually post here, it's for debugging, but I'm completely lost on this one guys. The brief statement is all the instruction I get on it too, so interpret at will. But it has to follow those outlines. Thanks for any help you can give. Sorry I'm so lost.