Just run this program and explain me output of last line why it prints "g" instead of "f". Here my intention is to know why it is showing previous functions return value?
#include <iostream>
#include <string>
std::string f() {
return "f";
}
std::string g() {
return "g";
}
int main() {
const char * s = f().c_str();
std::cout << "s = " << s << std::endl;
std::cout << "g() = " << g() << std::endl;
std::cout << "s = " << s << std::endl;
}