摘要: 引用 在C++中引用相当于给变量起一个别名 语法 数据类型 &别名 = 变量; #include <iostream> #include <cstdlib> using namespace std; void test01() { int a = 10; int &b = a; b = 100; c 阅读全文
posted @ 2020-10-30 23:00 小宇宙zjy 阅读(87) 评论(0) 推荐(0) 编辑
摘要: const 链接属性 C语言默认是外部链接属性 // test.c const int m_A = 0; // C语言下默认是外部链接属性 // main.c #include <stdio.h> int main() { extern const int m_A; // 告诉编译器外部有一个m_A 阅读全文
posted @ 2020-10-30 22:40 小宇宙zjy 阅读(83) 评论(0) 推荐(0) 编辑
摘要: C++对C的增强和拓展 增强 1. 全局变量检测增强 int a; int a = 0; int main(int argc,char *argv[]) { return EXIT_SUCCESS; } D:\CC++\C++\Day1\main.cpp|5|error: redefinition 阅读全文
posted @ 2020-10-30 21:54 小宇宙zjy 阅读(245) 评论(0) 推荐(0) 编辑
摘要: 命名空间 #include <iostream> #include <cstdio> // using namespace std::cout; // 使用std中的cout using namespace std; // 使用std中的所有定义 namespace A { int a = 0; } 阅读全文
posted @ 2020-10-30 21:09 小宇宙zjy 阅读(66) 评论(0) 推荐(0) 编辑