Hi
this is my generic class:
template<class T, class PrnT>
class PersonalVec {
public:
PersonalVec();
T &operator[](int index) const;
const T &operator[](int index) const;
private:
std::vector<T> _vec;
};
I'm required to implement 2 versions of [] operator:
one that will return a const reference and a regular one that will also return a reference.
When i compile it i get:
PersonalVec.hpp:23: error: ‘const T& PersonalVec<T, PrnT>::operator[](int) const’ cannot be overloaded
PersonalVec.hpp:22: error: with ‘T& PersonalVec<T, PrnT>::operator[](int) const
I've put either one of them as remark and then it does compile, so i guess they are colliding somehow. What is the problem and how can i fix it?
thank you!