I am learning Data Structures and came across Dynamic array. Now they are supposed to be resizable by creating a new loop and pasting it in new array. But when i take more values than the defined size, shouldn't it throw an error ?
Here's the code:
int main() {
int *arr= new int[3];
for (int i = 0; i < 6; i++)
cin >> arr[i];
for (int i = 0; i < 10; i++)
cout << arr[i] <<" ";
return 0;
}
The size of array is 3. I have taken 6 elements and displayed 10. I am confused how this happens.
Please help me understand.