行业知识
C到C++的敲门砖-1
2026-11-28 13:07:00
来源:互联网转载
文章目录
- 关键字
- 命名空间
- 输入和输出
- 缺省参数
- ���数重载
关键字
相较于C语言32个关键字:
auto double int struct break else long switch case enum register typedef char extern return union const float short unsigned continue for signed void default goto sizeof volatile do if while static c++的关键字变成了63个:
asm do if return try continue auto double short typedef for dynamic_cast int signed typeid public break else long sizeof typename throw case enum mutable static union wchar_t catch explicit namespace static_cast unsigned default char export new struct using friend class extern operator switch virtual register const false private template void true const_cast float protected this volatile while delete goto reinterpret_cast inline bool 显然多一个关键字,多一种可能性。>.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;}
上一篇:我的世界怎么解散服务器?