zoukankan      html  css  js  c++  java
  • Effective C++ 读后感笔记

    1.赋值不一定是初始化。例如

    AClassName::AClassName(const std::string &name, const std::string &address,
        const std::list<PhoneNumber> &phones)
    {
         theName = name;          //这些都是赋值
          theAddress = address; //而非初始化
          thePhones = phones;
         numTimesConsulted = 0;
    }
    
    AClassName::AClassName(const std::string &name, const std::string &address,
        const std::list<PhoneNumber> &phones)
        :theName(name),                //这些都是初始化
          theAddress(address),
         thePhones(phones),
         numTimesConsulted(0)
    {}        //构造函数本体不必做任何动作

    2.类的默认继承级别为private,而struct默认为public。

      PS:①public继承,基类成员保有自己的访问级别:基类的public为派生类的public,基类的protected为派生类的protected;②protected继承,基类的public和protected在派生类中为protected;

          ③private继承,基类所有成员在派生类中为private。

  • 相关阅读:
    第七周作业
    人月神话之没有银弹
    第六周作业
    第五周作业
    第四周作业
    第三周作业
    人月神话之沟通
    第二周作业
    第一周作业
    第八周作业
  • 原文地址:https://www.cnblogs.com/fengfengqingqingyangyang/p/3262526.html
Copyright © 2011-2022 走看看