int main() {
vector <int> multiples(1);
cout << multiples[0];
}
This returns 0 when I want it to be 1. This happens when I initialize the vector with one element, I can access the second element, however:
int main() {
vector <int> multiples(1, 4);
cout << multiples[1]; // 4
}
Moreover, when I try to access elements in the vector that do not exist, I get the value of the rightmost element (in this case, 4). But I cannot seem to get the first element however. Can anyone explain why?