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;   //   取值运算符

    };

  • 相关阅读:
    测试用例
    web 接口测试入门
    Web 安全测试
    Web 测试总结
    linux的基本操作(NFS服务配置)
    linux的基本操作(mysql 的基本操作)
    linux的基本操作(LNMP的基本操作)
    linux的基本操作(LAMP环境搭建)
    linux 的基本操作(linux系统的日常管理)
    Android官方技术文档翻译——ApplicationId 与 PackageName
  • 原文地址:https://www.cnblogs.com/superniaoren/p/3343587.html
Copyright © 2011-2022 走看看