Update README.md

This commit is contained in:
xliu79 2020-07-20 23:54:33 +08:00 committed by GitHub
parent 41c1311692
commit 282e93f21a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,18 +1,19 @@
# UNION那些事
# Story About Union
## 关于作者:
个人公众号:
![](../img/wechat.jpg)
联合union是一种节省空间的特殊的类一个 union 可以有多个数据成员,但是在任意时刻只有一个数据成员可以有值。当某个成员被赋值后其他成员变为未定义状态。联合有如下特点:
Unionis a space saving special class.A union can have multiple data members.However, only one data member can have a value at any time. When a member is assigned a value, other members become undefined.
- The default access control character is public
- It can contain constructors and destructors
- Cannot contain a member of a reference type
- Cannot inherit from other classes, cannot be a base class
- Cannot contain virtual functions
- Anonymous union can directly access union members in the scope of definition
- Anonymous union cannot contain protected or private members
- Global anonymous union must be static
- 默认访问控制符为 public
- 可以含有构造函数、析构函数
- 不能含有引用类型的成员
- 不能继承自其他类,不能作为基类
- 不能含有虚函数
- 匿名 union 在定义所在作用域可直接访问 union 成员
- 匿名 union 不能包含 protected 成员或 private 成员
- 全局匿名联合必须是静态static