走入C++程序世界-------第一个C++程序
下面就让我们走进C++的编程世界,目前介绍的都是在LINUX下的C++程序。废话少说,看下面经典的“hello world!"代码。
#include <string>#include <iostream>int main(){ using namespace std; /*声明并定义一个string对象*/ string str1 ("This is a C++ string! "); cout << "str1 = " << str1 << endl; string str2; str2 = str1; cout << "str2 = " << str2 << endl; /*直接赋值*/ str2 = "Hello string!"; cout << "赋值后的 str2 = " << str2 << endl; string str3; str3 = str1 + str2; cout << "the result of str1 + str2 is = " << str3 << endl; return 0;}