#include "stdafx.h"
#include <iostream>
#include <string>
using namespace std;
const char* funA()
{
return "aa"; // where does system to store this temporary variable?
}
// this is not an valid function
const char* funB()
{
string str("bb");
return str.c_str();
}
int _tmain(int argc, _TCHAR* argv[])
{
cout << funA() << endl;
cout << funB() << endl; // invalid
return 0;
}
Question> We should not return a pointer or reference to a local variable inside a function. So the return variable "aa" is not a local variable inside the function of funA. Then what is it?
Thank you