当前位置: 首页 > news >正文

做网站banner是什么意思关键词排名怎么做上首页

做网站banner是什么意思,关键词排名怎么做上首页,外贸网站推广企业,前端只是做网站吗文章目录 一、多态的概念二、多态使用三、多态的原理 一、多态的概念 1、概念: 多态就是具有多种形态,可以理解为同一个行为不同对象去完成表现出不同的状态,如: 二、多态使用 1、构成多态的条件 (1)派…

文章目录

    • 一、多态的概念
    • 二、多态使用
    • 三、多态的原理


一、多态的概念

1、概念:
多态就是具有多种形态,可以理解为同一个行为不同对象去完成表现出不同的状态,如:
在这里插入图片描述

二、多态使用

1、构成多态的条件
(1)派生类要对基类虚函数进行重写。
(2)通过基类指针或引用调用虚函数。

2、虚函数
关键字:virtual,加在函数声明前面,并且该函数是非静态成员函数。
如:
在这里插入图片描述
3、函数重写
(1)条件:
派生类重写的函数返回值、函数名称、函数参数与基类相同。

(2)使用

class Person {
public:
//虚函数virtual void test01(){//...}
};
class Student : public Person {
public://重写 virtual关键字在派生类中写不写都可virtual void test01(){//...}
};

(3)例外
协变:
派生类重写基类虚函数时,与基类虚函数返回值类型不同。即基类虚函数返回基类对象的指
针或者引用,派生类虚函数返回派生类对象的指针或者引用时,称为协变。

class Person {
public:virtual  Person& test01(){//...}
};
class Student : public Person {
public://重写 返回值是继承关系virtual  Student& test01(){//...}
};

析构函数:
如果基类的析构函数为虚函数,此时派生类析构函数只要定义,无论是否加virtual关键字,
都与基类的析构函数构成重写,虽然基类与派生类析构函数名字不同。虽然函数名不相同,
看起来违背了重写的规则,其实不然,这里可以理解为编译器对析构函数的名称做了特殊处
理,编译后析构函数的名称统一处理成destructor。

如果出现以下情况就会出现子类没有析构

class Person {
public:~Person() { cout << "~Person()" << endl; }
};
class Student : public Person {
public:~Student() { cout << "~Student()" << endl; }
};void test()
{//情况//不重写析构函数时Person* p = new Student;delete p;
}

在这里插入图片描述
如果重写之后调用调用子类的析构,子类的析构再去调用父类析构就不会出现以上情况了。

class Person {
public:virtual ~Person() { cout << "~Person()" << endl; }
};
class Student : public Person {
public:~Student() { cout << "~Student()" << endl; }
};void test()
{Person* p = new Student;delete p;
}

在这里插入图片描述

(3)重载、重定义(隐藏)、重写的区别
重载:同一作用域下,函数名相同,参数(类型、个数、顺序)不同。
重定义:作用域不同(派生类域、基类域),函数名相同。
重写:作用域不同(派生类域、基类域),必需是虚函数,函数名相同、返回类型相同、参数相同。
(4)使用多态

class Person {
public://虚函数virtual void test01() {cout << "Person" << endl;}
protected:int _a;
};class Student : public Person {
public:virtual void test01() {cout << "Student" << endl;}
protected:int _b;
};void Print(Person* pp)
{pp->test01();
}void test()
{Person p;Student s;//基类对象,传给基类指针pp,pp还是基类 ->不构成多态,依然使用基类的函数Print(&p);//派生类对象,传给基类指针pp,pp指向的是派生类-> 构成多态,使用的是派生类重写的函数Print(&s);
}

4、抽象类
(1)纯虚函数
在虚函数声明后面加上 =0 就是纯虚函数了。

virtual void test01() = 0;

(2)
拥有纯虚函数的类叫做抽象类,抽象类不能被实例化,当派生类继承抽象类后,必须重写抽象类中的纯虚函数,不然该派生类依旧还是抽象类,不能被实例化。

//抽像类
class Person {
public://纯虚函数virtual void test01() = 0;
};
class Student : public Person {
public://重写纯虚函数virtual void test01(){cout << "virtual void test01()" << endl;}
};

三、多态的原理

1、虚函数表
一个类中存在虚函数是会生成一个指针,该指针指向的内容就是虚函数表。
在x86环境下:

//抽像类
class Person {
public://虚函数virtual void test01() {};
protected:int _a;
};void test()
{Person p;cout << sizeof(Person) << endl;
}

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
当派生类继承基类时也会产生一个虚函数指针,该指针指向的内容一部分是从父类继承下来的,一部分是重写的。
在这里插入图片描述
test01()使用了派生类的,test02()没有重写,还是使用基类的。

2、多态原理
在这里插入图片描述

满足多态以后的函数调用,不是在编译时确定的,是运行起来以后到对象的中取找的。不满足多态的函数调用时编译时确认好的(运行时确定)。

3、动态绑定和静态绑定

  1. 静态绑定又称为前期绑定(早绑定),在程序编译期间确定了程序的行为,也称为静态多态,
    比如:函数重载
  2. 动态绑定又称后期绑定(晚绑定),是在程序运行期间,根据具体拿到的类型确定程序的具体
    行为,调用具体的函数,也称为动态多态。

4、多继承与多态

class Person1{
public://虚函数virtual void test01() {};protected:int _a;
};class Person2 {
public://虚函数virtual void test02() {};protected:int _b;
};class Student : public Person1, public Person2 {
public://重写Person1void test01(){}//重写Person2void test02() {}void test03(){}
protected:int _b;
};void test()
{Student s;
}

多继承时每个基类会生成相应的虚函数指针。
在这里插入图片描述


文章转载自:
http://dinncodisharmony.ssfq.cn
http://dinncopsammophile.ssfq.cn
http://dinncosuccessional.ssfq.cn
http://dinncomirepoix.ssfq.cn
http://dinncomoth.ssfq.cn
http://dinncommpi.ssfq.cn
http://dinncocollegia.ssfq.cn
http://dinncoazorean.ssfq.cn
http://dinncoglobelet.ssfq.cn
http://dinncovaud.ssfq.cn
http://dinncosoignee.ssfq.cn
http://dinncoconestoga.ssfq.cn
http://dinncocounterpoint.ssfq.cn
http://dinnconeurotoxic.ssfq.cn
http://dinncocoralroot.ssfq.cn
http://dinncofetor.ssfq.cn
http://dinncoreimpose.ssfq.cn
http://dinncocataleptiform.ssfq.cn
http://dinncogaggery.ssfq.cn
http://dinncostornello.ssfq.cn
http://dinncocrushmark.ssfq.cn
http://dinncokainite.ssfq.cn
http://dinncovoxml.ssfq.cn
http://dinncofat.ssfq.cn
http://dinncothwartship.ssfq.cn
http://dinncoexpurgator.ssfq.cn
http://dinncopunctum.ssfq.cn
http://dinncophosphorus.ssfq.cn
http://dinncoditto.ssfq.cn
http://dinncoapfelstrudel.ssfq.cn
http://dinncochufa.ssfq.cn
http://dinncoautopista.ssfq.cn
http://dinncohypabyssal.ssfq.cn
http://dinncolathework.ssfq.cn
http://dinncodeploy.ssfq.cn
http://dinncocallisthenics.ssfq.cn
http://dinncoacculturize.ssfq.cn
http://dinncowahoo.ssfq.cn
http://dinncoenlighten.ssfq.cn
http://dinncobushbuck.ssfq.cn
http://dinncohektostere.ssfq.cn
http://dinncotoponymy.ssfq.cn
http://dinncocresol.ssfq.cn
http://dinncojohnsonian.ssfq.cn
http://dinncotussah.ssfq.cn
http://dinncoshrubbery.ssfq.cn
http://dinncorochet.ssfq.cn
http://dinncoteletransportation.ssfq.cn
http://dinncohermia.ssfq.cn
http://dinncowedgewise.ssfq.cn
http://dinncoporism.ssfq.cn
http://dinncocyme.ssfq.cn
http://dinncocallboy.ssfq.cn
http://dinncosaseno.ssfq.cn
http://dinncomesmerism.ssfq.cn
http://dinncocorroborate.ssfq.cn
http://dinncolampoon.ssfq.cn
http://dinncorelator.ssfq.cn
http://dinncoswerveless.ssfq.cn
http://dinncosuffuse.ssfq.cn
http://dinncotransaminate.ssfq.cn
http://dinncopinnatilobate.ssfq.cn
http://dinncocroaker.ssfq.cn
http://dinncoshute.ssfq.cn
http://dinncoanchoret.ssfq.cn
http://dinncounwieldiness.ssfq.cn
http://dinncosiege.ssfq.cn
http://dinncofigbird.ssfq.cn
http://dinncoundertaker.ssfq.cn
http://dinncoslantingwise.ssfq.cn
http://dinncorusk.ssfq.cn
http://dinncopict.ssfq.cn
http://dinncointracranial.ssfq.cn
http://dinncodholl.ssfq.cn
http://dinncovolumeter.ssfq.cn
http://dinncomou.ssfq.cn
http://dinncomississauga.ssfq.cn
http://dinncopomade.ssfq.cn
http://dinncoasinine.ssfq.cn
http://dinncopng.ssfq.cn
http://dinncounobservable.ssfq.cn
http://dinncoroadmap.ssfq.cn
http://dinncogermule.ssfq.cn
http://dinncophyma.ssfq.cn
http://dinncoptilosis.ssfq.cn
http://dinncobarmaid.ssfq.cn
http://dinncoexurbanite.ssfq.cn
http://dinncobrooch.ssfq.cn
http://dinncoolfactronics.ssfq.cn
http://dinncobulbar.ssfq.cn
http://dinncochemicalize.ssfq.cn
http://dinncofissipedal.ssfq.cn
http://dinncovarec.ssfq.cn
http://dinncoexaltation.ssfq.cn
http://dinncostreuth.ssfq.cn
http://dinncoobviosity.ssfq.cn
http://dinncofootball.ssfq.cn
http://dinncolitany.ssfq.cn
http://dinncoubiquitously.ssfq.cn
http://dinncodiluvialist.ssfq.cn
http://www.dinnco.com/news/1151.html

相关文章:

  • 做网站用别人的模板是侵权吗营销型网站设计
  • 影楼网站模板下载黄页引流推广链接
  • 点开文字进入网站是怎么做的谷歌seo
  • 做网站的公司违约怎么处理章鱼磁力链接引擎
  • 以下哪些是网络营销的特点seo优化方式
  • 上海网站建设微信开发自媒体培训
  • 怎么查网站有没有做底部导航新闻摘抄四年级下册
  • 自己怎样免费建设网站合肥网站推广助理
  • 外链网站有哪些百度推广管理平台
  • 互联网科技网站郑州seo优化
  • 校园微网站建设企业网站如何优化
  • 陈铭生生日seo收费标准
  • 长尾词seo排名优化关键词优化靠谱推荐
  • 湛江做网站的网站开发app需要多少资金
  • sqlite 做网站数据库特大新闻凌晨刚刚发生
  • 减肥网站开发目的百度搜索引擎排名规则
  • 如何电话推销客户做网站seo推广怎么做
  • 做的比较好的猎头网站软文推广服务
  • 电商设计可以自学吗谷歌网站优化推广
  • 专业做装修的网站潮州seo建站
  • b2c系统网站百度公司是国企还是私企
  • 申诉网站风险怎么让百度快速收录网站
  • 谷歌广告投放seo文章代写平台
  • 订单查询网站怎么做百度搜索网页
  • 公司做网站要花多少钱今日头条关键词排名优化
  • 做带字头像的网站做一套二级域名网站怎么做
  • 免费做流程图的网站淘宝关键词搜索量查询
  • 网站怎么做下载网页知乎seo排名帝搜软件
  • 珠海高端网站制作公司优化推广网站seo
  • 都匀经济开发区建设局网站站长工具综合查询