front
描述 (Description)
它返回对字符串的第一个字符的引用。
声明 (Declaration)
以下是std :: string :: front的声明。
char& front();
C++11
const char& front() const;
参数 (Parameters)
没有
返回值 (Return Value)
它返回对字符串的第一个字符的引用。
异常 (Exceptions)
如果抛出异常,则字符串中没有变化。
例子 (Example)
在下面的示例中为std :: string :: front。
#include <iostream>
#include <string>
int main () {
std::string str ("Sairamkrishna Mammahe");
str.front() = 'A';
std::cout << str << '\n';
return 0;
}
Aairamkrishna Mammahe