0

Advantage of using At function in c++

What is the difference in accessing a character from string normally and by at function?

14th Feb 2019, 2:56 PM
Vishal kumar
Vishal kumar - avatar
1 Resposta
+ 2
The at function does out-of-bounds checking, it throws an std::out_of_range exception if you try to access out-of-bounds whereas the subscript operator does not perform any checks. Because of the check the at function is slower than the subscript operator but if you know what you're doing you usually don't need the at function anyway.
14th Feb 2019, 4:36 PM
Dennis
Dennis - avatar