服务器自带c++环境,无需安装!
测试c++环境
编写一个简单的c++程序 root文件夹下新建test.cpp文件
// myfirst.cpp--displays a message
#include <iostream> // make definitions visible
using namespace std;
int main() // function header
{ // start of function body
cout << "Come up and C++ me some time."; // message
cout << endl; // start a new line
cout << "You won't regret it!" << endl; // more output
return 10; // terminate main() 返回值为0代表成功,非0返回值的含义由系统自定义
} // end of function body
打开命令窗口进行编译
g++ -o test1 test.cpp
-o test1 test.cpp 从test.cpp编译生成test1文件,test1为可执行文件,没有后缀
执行可执行文件
root@aml:~# ./test1
Come up and C++ me some time.
You won't regret it!