简单类型 / 布尔

#include <iostream>
#include <sstream>
using namespace std;

bool sunIsStar = true;

//the first method
stringstream stream;
stream << boolalpha << sunIsStar;
string str = stream.str();
cout << "str is " << str << endl;

//the second method
str = sunIsStar ? "true" : "false";
//str is "true"
cout << "str is " << str << endl;