对于C++与C语言的不同,下面是一个简单的C++程序
#include<iostream>
using namespace std;
int main()
{
cout<<"Hello!"<<endl;
cout<<"Welcome to C++!"<<endl;
return 0;
}
头文件由“#include<stdio.h>”变为“#include<iostream>”
输出由“printf”变为“cout<<”
输入由“scanf”变为“cin>>”
换行由“\n”变为“endl”
而 using namespace std;是针对命名空间的指令。
C++中的关键字
asm auto bool break case catch char class const const_cast continue default
delete do double dynamic_cast else enum explicit export extern false float for
friend goto if inline int long mutable namespace new operator private protected
public register reinterpret_cast return short signed sizeof static static_cast struct
switch template this throw true try typedef typeid typename union unsigned
using virtual void volatile wchar_t while