<?xml version="1.0" encoding="utf-8" ?><rss version="2.0"><channel><title><![CDATA[每天积累一点点]]></title><description><![CDATA[]]></description><link>https://blog.csdn.net/lianghe_work</link><language>zh-cn</language><generator>https://blog.csdn.net/</generator><copyright><![CDATA[Copyright &copy; lianghe_work]]></copyright><item><title><![CDATA[50_菱形继承]]></title><link>https://blog.csdn.net/lianghe_work/article/details/106268295</link><guid>https://blog.csdn.net/lianghe_work/article/details/106268295</guid><author>lianghe_work</author><pubDate>Thu, 21 May 2020 21:46:41 +0800</pubDate><description><![CDATA[具有公共祖先 的多继承


class Animal
{
public:
    int data;
};

class Sheep:public Animal
{
public:
};
class Tuo:public Animal
{
public:
};

class SheepTuo:public Sheep,public Tuo
{
public:
};
int main(int argc, char *argv[])
{
    SheepTuo st;
    //SheepTuo 从Shee]]></description><category></category></item><item><title><![CDATA[49_多继承]]></title><link>https://blog.csdn.net/lianghe_work/article/details/106267783</link><guid>https://blog.csdn.net/lianghe_work/article/details/106267783</guid><author>lianghe_work</author><pubDate>Thu, 21 May 2020 21:17:08 +0800</pubDate><description><![CDATA[多继承的格式


class 子类: 继承方式1 父类名1,继承方式2 父类名2,继承方式3 父类名3,....
{

};
//表示子类 是由 父类名1,父类名2,父类名3...共同派生出来


class Base1
{
public:
    int a;
};
class Base2
{
public:
    int b;
};

class Son:public Base1,public Base2
{
    //Son类 拥有了a  b
};
int main(int argc, char ]]></description><category></category></item><item><title><![CDATA[48_继承中的静态成员特性]]></title><link>https://blog.csdn.net/lianghe_work/article/details/106267748</link><guid>https://blog.csdn.net/lianghe_work/article/details/106267748</guid><author>lianghe_work</author><pubDate>Thu, 21 May 2020 21:15:02 +0800</pubDate><description><![CDATA[class Base
{
public:
    //静态成员属于类 而不属于对象
    static int num;
    static int data;

    static void showData(void);

};
int Base::num  = 100;
int Base::data = 200;

class Son:public Base
{
public:
    static int data;//父和子类 静态成员 同名
    static void showDat.]]></description><category></category></item><item><title><![CDATA[47_父类和子类的同名 成员函数 处理]]></title><link>https://blog.csdn.net/lianghe_work/article/details/106267679</link><guid>https://blog.csdn.net/lianghe_work/article/details/106267679</guid><author>lianghe_work</author><pubDate>Thu, 21 May 2020 21:12:38 +0800</pubDate><description><![CDATA[案例：1子类继承父类所有成员函数 和成员变量


class Base
{
public:
    void func(void)
    {
        cout&lt;&lt;"父类中的void func"&lt;&lt;endl;
    }
    void func(int a)
    {
        cout&lt;&lt;"父类中的int func a = "&lt;&lt;a&lt;&lt;endl;
    }
};

class Son:public Base
{
public]]></description><category></category></item><item><title><![CDATA[46_父类和子类的同名 成员变量 处理]]></title><link>https://blog.csdn.net/lianghe_work/article/details/106223532</link><guid>https://blog.csdn.net/lianghe_work/article/details/106223532</guid><author>lianghe_work</author><pubDate>Tue, 19 May 2020 21:37:08 +0800</pubDate><description><![CDATA[1、当 父类和子类 成员变量同名时 在子类就近原则 选择本作用域的子类成员

2、如果在子类中 必须使用父类中的同名成员 必须加上父类的作用域。


class Base
{
    //父类的私有数据 一旦涉及继承 在子类中不可见
public:
    int num;
public:
    Base(int num)
    {
        this-&gt;num = num;
        cout&lt;&lt;"Base有参构造int"&lt;&lt;endl;
    }
    ~]]></description><category></category></item><item><title><![CDATA[45_详解 子类中的构造]]></title><link>https://blog.csdn.net/lianghe_work/article/details/106223428</link><guid>https://blog.csdn.net/lianghe_work/article/details/106223428</guid><author>lianghe_work</author><pubDate>Tue, 19 May 2020 21:29:15 +0800</pubDate><description><![CDATA[1、子类会默认调用 父类的 无参构造

2、子类 必须显示 使用初始化列表 调用 父类的有参构造

调用形式：父类名称。


Son(int a,int b):Base(a),b(b)
{
    //this-&gt;b = b;
}


class Base
{
private:
    int a;
public:

    Base()
    {
        cout&lt;&lt;"父类的无参构造函数"&lt;&lt;endl;
    }
    Base(int a)
    {
   ]]></description><category></category></item><item><title><![CDATA[44_子类中 有父类、对象成员 构造和析构的顺序]]></title><link>https://blog.csdn.net/lianghe_work/article/details/106223363</link><guid>https://blog.csdn.net/lianghe_work/article/details/106223363</guid><author>lianghe_work</author><pubDate>Tue, 19 May 2020 21:26:01 +0800</pubDate><description><![CDATA[父类的构造和析构 对象成员的构造和析构 子类自身的构造和析构

总结：（重要）




class Other
{
public:
    Other()
    {
        cout&lt;&lt;"对象成员的构造函数"&lt;&lt;endl;
    }
    ~Other()
    {
        cout&lt;&lt;"对象成员的析构函数"&lt;&lt;endl;
    }
};
class Base
{
public:
    Base()
    {
        co]]></description><category></category></item><item><title><![CDATA[43_继承中的构造和析构顺序]]></title><link>https://blog.csdn.net/lianghe_work/article/details/106108808</link><guid>https://blog.csdn.net/lianghe_work/article/details/106108808</guid><author>lianghe_work</author><pubDate>Wed, 13 May 2020 22:49:25 +0800</pubDate><description><![CDATA[class Base
{
public:
    Base()
    {
        cout&lt;&lt;"父类的无参构造函数"&lt;&lt;endl;
    }
    ~Base()
    {
        cout&lt;&lt;"父类中的析构函数"&lt;&lt;endl;
    }
};
class Son:public Base
{
public:
    Son()
    {
        cout&lt;&lt;"子类的无参构造"&lt;&lt;endl;
    .]]></description><category></category></item><item><title><![CDATA[42_继承的内层接结构]]></title><link>https://blog.csdn.net/lianghe_work/article/details/106108726</link><guid>https://blog.csdn.net/lianghe_work/article/details/106108726</guid><author>lianghe_work</author><pubDate>Wed, 13 May 2020 22:46:41 +0800</pubDate><description><![CDATA[当前演示在vstudio中


class Base
{
public:
    int a;
protected:
    int b;
private:
    int c;
};

class Son :public Base
{
public:
    int d;
    int e;
};
int main(int argc, char* argv[])
{
    cout &lt;&lt; sizeof(Son) &lt;&lt; endl;
    return 0;
}

步骤：



]]></description><category></category></item><item><title><![CDATA[41_继承和派生的概述]]></title><link>https://blog.csdn.net/lianghe_work/article/details/106108370</link><guid>https://blog.csdn.net/lianghe_work/article/details/106108370</guid><author>lianghe_work</author><pubDate>Wed, 13 May 2020 22:36:54 +0800</pubDate><description><![CDATA[1、继承和派生的概述



继承的优点：减少代码的冗余 提高代码的重用性

2、继承的格式


派生类定义格式：
   Class 派生类名 :  继承方式 基类名{
         //派生类新增的数据成员和成员函数
   };
   class 子类: 继承方式  父类名{
       //子类新增的数据成员和成员函数
   };



继承方式分类：

public ： 公有继承 （重要）

private ： 私有继承 

protected ： 保护继承

父类个数分类：

单继承：指...]]></description><category></category></item><item><title><![CDATA[40_不要重载&&、||]]></title><link>https://blog.csdn.net/lianghe_work/article/details/106087408</link><guid>https://blog.csdn.net/lianghe_work/article/details/106087408</guid><author>lianghe_work</author><pubDate>Tue, 12 May 2020 23:04:48 +0800</pubDate><description><![CDATA[不要重载&amp;&amp;、|| 因为 用户无法实现 &amp;&amp; ||的短路特性。

&amp;&amp; 短路特性： A &amp;&amp; B 如果A为假 B将不会执行

|| 短路特性： A || B 如果A为真 B将不会执行


#include &lt;iostream&gt;

using namespace std;

class Complex{
public:
    Complex(int flag){
        this-&gt;flag = flag;
    }]]></description><category></category></item><item><title><![CDATA[39_函数调用符（）的重载]]></title><link>https://blog.csdn.net/lianghe_work/article/details/106087358</link><guid>https://blog.csdn.net/lianghe_work/article/details/106087358</guid><author>lianghe_work</author><pubDate>Tue, 12 May 2020 23:01:53 +0800</pubDate><description><![CDATA[#include &lt;iostream&gt;

using namespace std;
class Fun
{
public:
    int my_add(int x,int y)
    {
        return x+y;
    }
    //重载()
    //第一个()是重载的符号 第二个（）是标明要传参
    int operator()(int x,int y)
    {
        return x+y;
    }
};

void test01()
{
  .]]></description><category></category></item><item><title><![CDATA[38_等于和不等于(==、!=)运算符重载]]></title><link>https://blog.csdn.net/lianghe_work/article/details/106087312</link><guid>https://blog.csdn.net/lianghe_work/article/details/106087312</guid><author>lianghe_work</author><pubDate>Tue, 12 May 2020 22:59:40 +0800</pubDate><description><![CDATA[//重载==  ==出现在判断语句中
    bool operator==(Person &amp;ob)
    {
        if(strcmp(this-&gt;name, ob.name) == 0)
        {
            return true;
        }
        return false;
    }
    //重载!=  !=出现在判断语句中
    bool operator!=(Person &amp;ob)
    {
        .]]></description><category></category></item><item><title><![CDATA[37_重载=运算符]]></title><link>https://blog.csdn.net/lianghe_work/article/details/106064009</link><guid>https://blog.csdn.net/lianghe_work/article/details/106064009</guid><author>lianghe_work</author><pubDate>Mon, 11 May 2020 22:17:08 +0800</pubDate><description><![CDATA[前提1：类中 没有指针成员 不需要重载=运算符（默认的浅拷贝就可以完成）


#include &lt;iostream&gt;

using namespace std;
class Person
{
private:
    int a;
    int b;
public:
    Person():a(0),b(0)
    {
        cout&lt;&lt;"无参构造"&lt;&lt;endl;
    }
    Person(int a, int b):a(a),b(b)
    {]]></description><category></category></item><item><title><![CDATA[36_重载指针运算符* ->]]></title><link>https://blog.csdn.net/lianghe_work/article/details/106063971</link><guid>https://blog.csdn.net/lianghe_work/article/details/106063971</guid><author>lianghe_work</author><pubDate>Mon, 11 May 2020 22:13:32 +0800</pubDate><description><![CDATA[#include &lt;iostream&gt;

using namespace std;
class Person
{
private:
    int num;
public:
    Person(int num):num(num)
    {
        //this-&gt;num = num;
        cout&lt;&lt;"有参构造num = "&lt;&lt;num&lt;&lt;endl;
    }

    void showPerson(void)
    {
 .]]></description><category></category></item><item><title><![CDATA[35_重载自增运算符]]></title><link>https://blog.csdn.net/lianghe_work/article/details/106063164</link><guid>https://blog.csdn.net/lianghe_work/article/details/106063164</guid><author>lianghe_work</author><pubDate>Mon, 11 May 2020 21:37:39 +0800</pubDate><description><![CDATA[1、可重载的运算符



2、重载自增 或自减 ++ --运算符

operator++

编译器看到++a(前置++)，它就调用operator++(a),当编译器看到a++（后置++），它就会去调用operator++(a,int).


#include &lt;iostream&gt;

using namespace std;
class Data
{
    friend ostream&amp; operator&lt;&lt;(ostream &amp;out, Data &amp;ob);]]></description><category></category></item><item><title><![CDATA[34_重载加法运算符]]></title><link>https://blog.csdn.net/lianghe_work/article/details/106005576</link><guid>https://blog.csdn.net/lianghe_work/article/details/106005576</guid><author>lianghe_work</author><pubDate>Fri, 08 May 2020 20:37:49 +0800</pubDate><description><![CDATA[1、全局函数作为友元 完成运算符重载+

1+1 这种情况下 不需要重载 编译器能够计算


#include &lt;iostream&gt;
#include&lt;string.h&gt;
using namespace std;
class Person
{
    //设置成友元函数 在函数内 访问Person类中的所有数据
    friend ostream&amp; operator&lt;&lt;(ostream &amp;out, Person &amp;ob);
    friend ]]></description><category></category></item><item><title><![CDATA[33_运算符输出重载]]></title><link>https://blog.csdn.net/lianghe_work/article/details/106005430</link><guid>https://blog.csdn.net/lianghe_work/article/details/106005430</guid><author>lianghe_work</author><pubDate>Fri, 08 May 2020 20:28:19 +0800</pubDate><description><![CDATA[1、重载运算符的概述

运算符重载，就是对已有的运算符重新进行定义，赋予其另一种功能，以适应不同的数据类型

运算符重载的目的：简化操作 让已有的运算符 适应适应不同的数据类型。

语法：函数的名字由关键字operator及其紧跟的运算符组成

比如：重载+运算符 ==&gt;operator+ 重载=号运算 ==&gt;operator=

注意：重载运算符 不要更改 运算符的本质操作（+是数据的相加 不要重载成相减）

2、重载&lt;&lt;运算符


#include &lt;iostream&gt]]></description><category></category></item><item><title><![CDATA[32_一个类整体作为另一个类的友元]]></title><link>https://blog.csdn.net/lianghe_work/article/details/106005113</link><guid>https://blog.csdn.net/lianghe_work/article/details/106005113</guid><author>lianghe_work</author><pubDate>Fri, 08 May 2020 20:08:19 +0800</pubDate><description><![CDATA[一个类的所有成员函数 访问 另一个类的私有数据


#include &lt;iostream&gt;

using namespace std;
class Room;//Room向前声明
class GoodGay
{
public:
    void visit1(Room &amp;room);//此处的Room 被上方 class Room
    void visit2(Room &amp;room);
};


class Room
{
    //将GoodGay作为Room的友元
    ]]></description><category></category></item><item><title><![CDATA[31_友元函数]]></title><link>https://blog.csdn.net/lianghe_work/article/details/105848466</link><guid>https://blog.csdn.net/lianghe_work/article/details/105848466</guid><author>lianghe_work</author><pubDate>Wed, 29 Apr 2020 20:55:55 +0800</pubDate><description><![CDATA[c++允许 友元 访问 私有数据。

友元的语法：

friend关键字只出现在声明处 其他类、类成员函数、全局函数都可声明为友元 友元函数不是类的成员，不带this指针 友元函数可访问对象任意成员属性，包括私有属性

1、普通全局函数 作为 类的友元


//房间类
class Room
{
    //将goodGayVisit作为类的友元函数
    //goodGayVisit 访问 类中...]]></description><category></category></item></channel></rss>