#include#include int main() { std::string str = "Hello world!"; std::cout << "Last character: " << str.back() << std::endl; return 0; }
#includeOutput: Modified string: Hello world? In both examples, the C++#include int main() { std::string str = "Hello world!"; str.back() = '?'; std::cout << "Modified string: " << str << std::endl; return 0; }