首先,初学C++,源代码是必不可少的:
#include<iostream>//输入输出流ostream+istream
using namespace std;
//Cin,Cout
int main()//主函数
{
ios::sync_with_stdio(false);
//输入输出优化,不一定要加上↑
return 0;//返回值
}
在介绍几种头文件:
【头文件】C++的常用头文件
好了,下面写几个实例程序:
1. Hello World!
#include<bits/stdc++.h>
using namespace std;
int main()
{
cout<<"Hello World!";
return 0;
}
如果你不写using namespace std;
那么程序长这样:
#include<bits/stdc++.h>
using namespace std;
int main()
{
std::cout<<"Hello World!";
return 0;
}
好了,C++基础就讲到这里,下次再见!!