Why does this:
#include
#include
using namespace std;
class Sandbox
{
public:
Sandbox(const string& n) : member(n) {
you're referring to something which has vanished. The following will work
#include
#include
class Sandbox
{
public:
const string member = " "; //default to whatever is the requirement
Sandbox(const string& n) : member(n) {}//a copy is made
};
int main()
{
Sandbox sandbox(string("four"));
std::cout << "The answer is: " << sandbox.member << std::endl;
return 0;
}