It returns a reference to the first character of the string.
Following is the declaration for std::string::front.
char& front();
const char& front() const;
none
It returns a reference to the first character of the string.
if an exception is thrown, there are no changes in the string.
In below example for 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