When I do this:
std::vector hello;
Everything works great. However, when I make it a vector of references instead:
As the other comments suggest, you are confined to using pointers. But if it helps, here is one technique to avoid facing directly with pointers.
You can do something like the following:
vector iarray;
int default_item = 0; // for handling out-of-range exception
int& get_item_as_ref(unsigned int idx) {
// handling out-of-range exception
if(idx >= iarray.size())
return default_item;
return reinterpret_cast(*iarray[idx]);
}