wrote:
> Hi,
>
> What will happen if i access an element which is bigger than the
> container?
> e.g.
> vector<int> aVector(1);
> cout << aVector[6] << endl?
/the above line causes undefined behaviour, ANYTHING could happen from
now one.
> // or can I do this:
> aVector[6] = 3;
//Same as above
> How about a Map?
> map<int, int> aMap(1);
> aMap[2] = 1;
> aMap[1] = 2;
No, they are both fine, assuming you remove the UB above.
What book are you reading that does not discuss this?
Ben Pope
--
I'm not just a number. To many, I'm known as a string...