CHAPTER2-20.cpp
上传用户:fjc899
上传日期:2007-07-03
资源大小:187k
文件大小:1k
- //文件名:CHAPTER2-20.cpp
- #pragma warning(disable:4786)
- #include <string>
- #include <iostream>
- using namespace std ;
- void main()
- {
- string result;
- string S1="ABC";
- string S2="DEF";
- char CP1[]="GHI";
- char C='J';
- cout << "S1 is " << S1 << endl;
- cout << "S2 is " << S2 << endl;
- cout << "CP1 is " << CP1 << endl;
- cout << "C is " << C << endl;
- result=S1+CP1; //语法1 (ABCGHI)
- cout << "S1+CP1 is " << result << endl;
- result=CP1+S1; //语法2 (GHIABC)
- cout << "CP1+S1 is " << result << endl;
- result=S1+S2; //语法3 (ABCDEF)
- cout << "S1+S2 is " << result << endl;
- result=S1+C; //语法4 (ABCJ)
- cout << "S1+C is " << result << endl;
- result=C+S1; //语法5 (JABC)
- cout << "C+S1 is " << result << endl;
- result+=S1;
- cout << "C+S1 is " << result << endl;
- result+=S2;
- cout << "C+S2 is " << result << endl;
- }