C++ 基础
2016-05-09 16:56
302 查看
1.当C++创建一个空类的时候,编译器会默认创建6个函数:
构造函数,析构函数,赋值函数,拷贝函数,取址运算符,取址运算符const
class Empty
{
public:
Empty{}
~Empty(){}
Empty(const Empty &){}
Empty &operator=(const Empty &){}
Empty *operator&(){}
const Empty *operator&()const{}
};
void main(int argc, char *argv[])
{
/*缺省构造函数*/
Empty empty1;
Empty empty2;
/*赋值运算符*/
empty1 =
empty2;
/*拷贝构造函数*/
Empty
empty3(empty1)
/*取址运算符*/
&empty1;
Empty const empty4;
/*取址运算符const*/
&empty4;
}
构造函数,析构函数,赋值函数,拷贝函数,取址运算符,取址运算符const
class Empty
{
public:
Empty{}
~Empty(){}
Empty(const Empty &){}
Empty &operator=(const Empty &){}
Empty *operator&(){}
const Empty *operator&()const{}
};
void main(int argc, char *argv[])
{
/*缺省构造函数*/
Empty empty1;
Empty empty2;
/*赋值运算符*/
empty1 =
empty2;
/*拷贝构造函数*/
Empty
empty3(empty1)
/*取址运算符*/
&empty1;
Empty const empty4;
/*取址运算符const*/
&empty4;
}
相关文章推荐
- 简单总结C++中的修饰符类型
- [C++]高精度 bign (重载运算符版本)
- C++学习曲线
- c++函数模板
- Caffe图片特征提取(Python/C++)
- C++中的运算符和运算符优先级总结
- 转 C++STL之string
- c++模板类成员的声明和定义
- 【C语言】矩阵转置
- Dual Palindromes
- 如何在Visual Studio和CodeBlocks中反编译C++代码
- 冒泡排序C++实现
- C语言的组成:32个关键词、9种控制语句、34种运算符
- 解析C++中的5个存储类的作用
- C++文件读写
- C#和C++除了语法上的差别外,还有什么其他的区别
- stdio.h
- Slight difference between C++ and C
- C++入门之基础语法学习教程
- C++程序设计语言练习4.3