I am trying to write a class that has a vector member. I want to make certain methods of this vector (not all) available like this:
#include <vector>
template <class T>
class Test
{
private:
std::vector<T> myVec;
public:
std::vector<T>::const_reference back() const
{
return dataVector.back();
}
};
int main()
{
Test<float> myTest();
}
However, I get these errors:
test.cpp(15): error C2061: syntax error: identifier 'const_reference'
test.cpp(16): error C2334: unexpected token(s) preceding '{'; skipping apparent function body
and a warning:
test.cpp(15): warning C4346: 'const_reference': dependent name is not a type
Which I do not understand.
Questions
- What is the issue the errors and warnings are complaining about?
- How can I expose this vector function correctly?