例子:
#include <iostream>
#include <string>
using namespace std;
int main(){
string strinfo="Alis";
if( strinfo == "winter" )
cout << "you are winter!"<<endl;
else if( strinfo != "wende" )
cout << "you are not wende!"<<endl;
else if( strinfo < "winter")
cout << "your name should be ahead of winter"<<endl;
else
cout << "your name should be after of winter"<<endl;
cout << strinfo + " Welcome to China!"<<endl;
cout <<"Your name is :"<<endl;
string strtmp = "How are you? " + strinfo;
for(int i = 0 ; i < strtmp.size(); i ++)
cout<<strtmp[i];
return 0;
}
输出:
you are not wende!
Alis Welcome to China!
Your name is :
How are you? Alis