vector::at question??

Ok I have a for loop that displays what's at position i in vector v2.However, I am getting the error "A reference of type "std::string &" (not const qualified) cannot be initialized with a value of type "int"

cout << v2.at(i) << " ";

Implementation file:
1
2
3
4
5
6
7
8
9
10
11
12
13
// Testing index to see if less than size. If bigger throw error
template<typename T>
T Vector<T>::at(T index)
{
		if(index < size)
		{
			return elements[index];
		}
		else
		{
			throw range_error("Index out of bounds!");
		}
}


Header file:
T at(T &index);
Shouldn't it be:
1
2
template<typename T>
T& Vector<T>::at(size_t index)

Topic archived. No new replies allowed.