0

Is bound checking in c++ language possible or not?

Can we insert elements in an array more than its size?

15th Dec 2016, 5:16 PM
Nitul Sahu
Nitul Sahu - avatar
2 Respostas
0
Yes, you can and the compiler will quite happily allow it in both C/C++. C/C++ always errs on the side of max performance, so it considers the costs of automatic bounds checking inserted by the compiler as too high. This is perfectly legal C/C++: int* p = new int[10] ; for(int i=0; I < 1000; i++) *(p+i) = 5+i; But you can always roll your own bounds checking if required.
15th Dec 2016, 5:46 PM
Ettienne Gilbert
Ettienne Gilbert - avatar
0
Thanks
16th Dec 2016, 12:21 AM
Nitul Sahu
Nitul Sahu - avatar