摘要: 1 const 问题:const 所修饰的标识符,什么时候为只读变量,什么时候是常量 const 常量的判别准则 只有用字面量初始化的 const 常量才会进入符号表 使用其他变量初始化的 const 常量仍然是只读变量 被 volatile 修饰的 const 常量不会进入符号表 在编译期间不能直 阅读全文
posted @ 2020-09-21 23:43 nxgy 阅读(155) 评论(0) 推荐(0) 编辑
摘要: 1 C 语言中的强制类型转换 C 方式的强制类型转换 (Type)(Expression) Type(Expression) 示例:粗暴的类型转换 Demo #include <stdio.h> typedef void(PF)(int); //定义一个函数类型 struct Point { int 阅读全文
posted @ 2020-09-21 21:44 nxgy 阅读(102) 评论(0) 推荐(0) 编辑
摘要: 1 动态内存分配 C++ 中的动态内存分配 C++ 中通过 new 关键字进行动态内存分配 C++ 中的动态内存申请是基于类型进行的 delete 关键字用于内存释放 //变量申请 Type* pointer = new Type; //... delete pointer; //数组申请 Type 阅读全文
posted @ 2020-09-21 21:42 nxgy 阅读(115) 评论(0) 推荐(0) 编辑
摘要: 1 C++ 中的函数重载 函数重载(Function Overload) 用同一个函数名定义不同的函数 当函数名和不同的参数搭配时函数的含义不同 示例 Demo #include <stdio.h> #include <string.h> int func(int x) { return x; } 阅读全文
posted @ 2020-09-21 21:40 nxgy 阅读(171) 评论(0) 推荐(0) 编辑
摘要: 1 函数参数的默认值 C++ 中可以在函数声明时为参数提供一个默认值 当函数调用时没有提供参数的值,则使用默认值 int mul(int x = 0); int main(int argc,char* argv[]) { printf("%d\n",mul()); // <=> mul(0) ret 阅读全文
posted @ 2020-09-21 21:39 nxgy 阅读(82) 评论(0) 推荐(0) 编辑