Wikipedia tells me that
Reference is a simple reference datatype that is less powerful but safer than the pointer type inherited from C
I am learning C++ and I came across the function vector::front().
In the documentation it says the fuction
Returns a reference to the first element in the vector.
However, as shown in the code below, the return value is treated as not the reference but the element itself.
vector<int> my_vector(1); // initialising a vector
my_vector.push_back(10); // inserting 10
int number = my_vector.front() + 1; // number = 11
If my_vector.front() is a reference to the first element, shouldn't it be dereferenced with (*) in order to access the value?
Seeing that
*my_vector.begin() == my_vector.front() == 10
and I can do arithmetics to the iterator, should I think of iterators as something similar to pointers in C, and think of reference as a value?