摘要: const分配内存的时机,编译器编译的时候分配内存 const相当于宏,用来取代c语言的#define #include<iostream> using namespace std; void main() { int a = 20; const int b = 30; const int d = 阅读全文
posted @ 2019-11-26 17:16 saintdingtheGreat 阅读(297) 评论(0) 推荐(0) 编辑
摘要: 命名空间 register 在C语言横行的时代,为了加快运行速度,一些关键变量会被放入寄存器中,程序代码请求编译器把变量存入寄存器,然而C语言版的寄存器变量无法通过地址获得register变量。c++仍然支持关键字register #include "iostream" #include<strin 阅读全文
posted @ 2019-11-26 16:31 saintdingtheGreat 阅读(318) 评论(0) 推荐(0) 编辑
摘要: 有人把类说成是占用固定大小内存块的别名,其定义时不占用空间 #include<iostream> #include<string> using namespace std; class mycoach { public: string name="陈培昌"; int age=22; private: 阅读全文
posted @ 2019-11-26 13:52 saintdingtheGreat 阅读(684) 评论(0) 推荐(0) 编辑