#include <vector>
#include <iostream>
using namespace std;
vector<int> vec;
int main() {
vec.push_back(1);
cout << vec[100];
}
this output it 0
but,
#include <vector>
#include <iostream>
using namespace std;
vector<int> vec;
int main() {
cout << vec[100];
}
this is error that is 'out of range'
so In case after vec.push_back(1), I wonder why I can access 100 index.
Aucun commentaire:
Enregistrer un commentaire