惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

雷峰网
雷峰网
L
LangChain Blog
GbyAI
GbyAI
F
Fortinet All Blogs
腾讯CDC
Last Week in AI
Last Week in AI
A
About on SuperTechFans
J
Java Code Geeks
Microsoft Azure Blog
Microsoft Azure Blog
博客园 - Franky
B
Blog
D
Docker
G
Google Developers Blog
月光博客
月光博客
博客园 - 三生石上(FineUI控件)
S
SegmentFault 最新的问题
Apple Machine Learning Research
Apple Machine Learning Research
酷 壳 – CoolShell
酷 壳 – CoolShell
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
T
Tailwind CSS Blog
宝玉的分享
宝玉的分享
U
Unit 42
Blog — PlanetScale
Blog — PlanetScale
B
Blog RSS Feed

博客园 - avisnet

枚举浏览器窗口 关闭弹出式IE浏览器窗口编程 iframe自适应高度 - avisnet - 博客园 实现集合类的帮助函数 FormView 在对话框里面使用ON_UPDATE_COMMAND_UI映射工具条 automation服务器不能创建对象 汇率 无题 [转]猪的爱情故事 在新窗口中打开网页,同时关闭原有窗口 删除文件至回收站而不是永久删除 低层键盘钩子 使用SqlServer模式的会话状态管理 Session Data Is Lost When You Use ASP.NET InProc Session State Mode [转]LINK : warning LNK4089: all references to "xxx.dll" discarded by /OPT:REF VC++中消除警告 const与typedef的中高级使用 在 ASP.NET 中执行 URL 重写
C++编译器默认声明的成员函数
avisnet · 2006-09-22 · via 博客园 - avisnet

按照c++标准,编译器会生成五个默认成员函数:

  • 默认构造函数
  • 拷贝构造函数
  • 析构函数
  • operator=
  • operator&

一个空的class在C++编译器处理过后就不再为空,编译器会自动地为我们声明一些member function,如果你写 :

class Empty {};

就相当于:

class Empty

{

public:

    Empty();  

    Empty(const Empty&);

    ~Empty();

    Empty& operator=(const Empty& rhs);

    Empty* operator&();

    const Empty* operator&() const;

};

需要注意的是只有当你需要用到这些函数的时候,编译器才会去定义它们。