at
语法:reference at( size_type index ); |
at()函数返回一个引用,指向在index位置的字符. 如果index不在字符串范围内, at() 将报告"out of range"错误,并抛出out_of_range异常。 比如下列代码:
string text = "ABCDEF"; char ch = text.at( 2 );
显示字符 'C'.
reference at( size_type index ); |
at()函数返回一个引用,指向在index位置的字符. 如果index不在字符串范围内, at() 将报告"out of range"错误,并抛出out_of_range异常。 比如下列代码:
string text = "ABCDEF"; char ch = text.at( 2 );
显示字符 'C'.