小工具知识网

当前位置: 首页 > 行业知识 > C到C++的敲门砖-1

行业知识

C到C++的敲门砖-1

2026-11-28 13:07:00 来源:互联网转载

文章目录

  • 关键字
  • 命名空间
  • 输入和输出
  • 缺省参数
  • ���数重载

    关键字

    相较于C语言32个关键字:

    autodoubleintstruct
    breakelselongswitch
    caseenumregistertypedef
    charexternreturnunion
    constfloatshortunsigned
    continueforsignedvoid
    defaultgotosizeofvolatile
    doifwhilestatic

    c++的关键字变成了63个:

    asmdoifreturn
    trycontinueautodouble
    shorttypedeffordynamic_cast
    intsignedtypeidpublic
    breakelselongsizeof
    typenamethrowcaseenum
    mutablestaticunionwchar_t
    catchexplicitnamespacestatic_cast
    unsigneddefaultcharexport
    newstructusingfriend
    classexternoperatorswitch
    virtualregisterconstfalse
    privatetemplatevoidtrue
    const_castfloatprotectedthis
    volatilewhiledeletegoto
    reinterpret_castinlinebool

    显然多一个关键字,多一种可能性。>.printf("%d\n", rand);return 0;} // 命名空间中可以定义变量/函数/类型 int rand = 10; int Add(int left, int right) { return left + right; } struct Node { struct Node* next; int val; }; }namespace test2 { double rand = 10.; } double rand = 10.; }using namespace std;using namespace test2;int main(){cout double rand = 10.; }using namespace test2;int main(){std::cout double rand = 10.; }using namespace test2;using std::cout;int main(){coutreturn a+b;}return a+b;} cout coutreturn a+b;}double Add(double a,double b){return a+b;}

上一篇:我的世界怎么解散服务器?

下一篇:linux服务器怎么开启ftp服务器?