- 博客(2)
- 收藏
- 关注
原创 error C2582
类创建的对象当含有成员常量(const)不能直接赋值 //当类中有引用,常量定义时,编译器不会为其生成‘=’运算符的函数。 /*C++不允许让reference改指向不同对象 引用的特点: ①一个变量可取多个别名。 ②引用必须初始化。 ③引用只能在初始化的时候引用一次 ,不能更改为转而引用其他变量。 */ #include <iostream> using namespace std; class A{ public: int value; const int constValue;
2020-07-07 17:48:23 307 1
原创 类的前置声明
一种让两者互为成员的方式; 文件A; #pragma once #include<iostream> using namespace std; class B; class A { B * m_B; } 文件B #pragma once #include<iostream> #include "A.h" using namespace std; class B { class A; }
2020-07-07 16:36:10 96
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人