Accessing Array Elements: i vs. .at(i)

  • Context: C/C++ 
  • Thread starter Thread starter ineedhelpnow
  • Start date Start date
  • Tags Tags
    Array Elements
Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
1 reply · 2K views
ineedhelpnow
Messages
649
Reaction score
0
ok I am a little confused.
can both and .at(i) be used to same way to access an array element?
 
Physics news on Phys.org
The [m].at(n)[/m] function automatically checks whether $n$ is within the bounds of valid elements in the vector, throwing an out_of_range exception if it is not (i.e., if $n$ is greater or equal than its size). This is in contrast with member operator[], that does not check against bounds.