#include <iostream>
#include <sstream>
using namespace std;
bool sunIsStar = true;
//第一种方法
stringstream stream;
stream << boolalpha << sunIsStar;
string str = stream.str();
cout << "str is " << str << endl;
//第二种方法
str = sunIsStar ? "true" : "false";
//str is "true"
cout << "str is " << str << endl;