I'm pretty new to C++ and I've only used high level languages before.
Here is my question. It's only for trying some things out.
#include <iostream>
#include <vector>
using namespace std;
int main() {
vector<int> ve(10);
for (unsigned int i; i < ve.size(); i++) {
ve[i] = i+1;
cout << ve[i] << endl;
}
cout << "Done filling vector. Now showing" << endl;
for (unsigned int y; y < ve.size(); y++) {
cout << ve[y] << endl;
}
cout << "We're done" << endl;
}
With the first "for" I want to fill the vector/array with values and output those values.
The second one is supposed to output them all again. However this doesn't happen. the array seems to be empty after the first for is done.
iwill contain garbage if you don't initialize it. (Whereas in Java it would have been 0).