zoukankan      html  css  js  c++  java
  • 笔试题 1.7 C++中定义一个空类,编译器都会做些什么

    class Empty

    {

      public:

          Empty(); // 缺省构造函数

          Empty( const Empty& ); // 拷贝构造函数

          ~Empty(); // 析构函数

           Empty& operator=( const Empty& ); // 赋值运算符

           Empty* operator&(); // 取址运算符

           const Empty* operator&() const; // 取址运算符 const

    };

    默认构造函数 
    析构函数 
    拷贝构造函数 
    赋值运算符(operator=) 
    取址运算符(operator&)(一对,一个非const的,一个const的) 

         当然,所有这些只有当被需要才会产生。比如你定义了一个类,但从来定义过该类的对象,也没使用过该类型的函数参数,那么

    基本啥也不会产生。在比如你从来没有进行过该类型对象之间的赋值,那么operator=不会被产生。

    class Empty
    {
    public:
              Empty();                  //   缺省构造函数

              Empty(const   Empty&);    //   拷贝构造函数

              ~Empty();                 //   析构函数

              Empty& perator=(const Empty&); //   赋值运算符

               Empty* operator&();              //   取值运算符
              const Empty* operator&() const;   //   取值运算符

    };

  • 相关阅读:
    ubuntu下管理android手机
    ubuntu下管理android手机
    ubuntu下管理android手机
    常用开源<监控软件>介绍
    常用开源<监控软件>介绍
    我的坦克兵爷爷也曾扬威世界
    bootstrap-巨幕、缩略图、警告框
    bootstrap-面包屑和分页
    bootstrap-导航条
    bootstrap-导航、选项卡
  • 原文地址:https://www.cnblogs.com/superniaoren/p/3343587.html
Copyright © 2011-2022 走看看