Here's the code:
vector<double> samples;
int main()
{
samples.resize(100);
for(int i=0; i<100; i++) {
samples[i]=i/100.0;
}
samples.clear();
cout << "vector size: " << samples.size() << endl;
cout << "... but samples[9]=" << samples[9] << endl;
}
And the output it:
vector size: 0
... but samples[9]=0.09
After clearing the vector (size is 0) I can still access to its data. Is it that normal?
Reference says elements will be "destroyed", but it seems it doesn't mean "default/empty" values.
In other languages I would get a "out of range" error message at runtime...