Talk About Network

Google





Programming > C - C++ Learning > Re: Lesson 5, A...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 4 of 4 Topic 4109 of 4400
Post > Topic >>

Re: Lesson 5, Arrays, Static, Dynamic, Multi Dimesional.

by "Alf P. Steinbach" <alfps@[EMAIL PROTECTED] > Apr 14, 2008 at 06:16 PM

* Hal Vaughan:
> Alf P. Steinbach wrote:
> 
>> * TheDevil:
>>> [raw] Arrays in C/C++ ... can lead to hard to find bugs pretty easily.
>> Yes, that's right.
>>
>> As a novice, preferentially use std::vector, and use 'at(i)' rather
than
>> '[i]'.
> 
> Why use at(i) over [i]?

Because it reacts to indexing errors by throwing an exception, instead of 
silently producing an incorrect result or tra****ng some memory area.

In other words, it provides guaranteed bounds-checking.

So it's much easier to detect those nefarious bugs.


Cheers, & hth.,

- Alf
 




 4 Posts in Topic:
Lesson 5, Arrays, Static, Dynamic, Multi Dimesional.
"TheDevil" <  2008-04-13 01:52:31 
Re: Lesson 5, Arrays, Static, Dynamic, Multi Dimesional.
"Alf P. Steinbach&qu  2008-04-13 02:34:14 
Re: Lesson 5, Arrays, Static, Dynamic, Multi Dimesional.
Hal Vaughan <hal@[EMAI  2008-04-14 15:36:55 
Re: Lesson 5, Arrays, Static, Dynamic, Multi Dimesional.
"Alf P. Steinbach&qu  2008-04-14 18:16:19 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
localhost-V2008-12-19 Wed Jan 7 10:07:05 PST 2009.