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

建设银行储蓄卡申请网站企业宣传册模板免费下载

建设银行储蓄卡申请网站,企业宣传册模板免费下载,微信开发者平台怎么登,三统文化传播网站1思维导图 2试编程 要求: 封装一个动物的基类#xff0c;类中有私有成员#xff1a;姓名#xff0c;颜色#xff0c;指针成员年纪 再封装一个狗这样类#xff0c;共有继承于动物类#xff0c;自己拓展的私有成员有#xff1a;指针成员#xff1a;腿的个数思维导图 2试编程 要求: 封装一个动物的基类类中有私有成员姓名颜色指针成员年纪 再封装一个狗这样类共有继承于动物类自己拓展的私有成员有指针成员腿的个数整型 int count共有成员函数会叫void speak() 要求分别完成基类和派生类中的构造函数、析构函数、拷贝构造函数、拷贝赋值函数 eg : Dog d1; Dog d2(.....); Dog d3(d2); d1 d3; 源代码: #include iostreamusing namespace std; //封装一个动物的基类 class Animal { //类中有私有成员姓名颜色指针成员年纪 private:string name;string color;double *age;public://Animal无参拷贝Animal(){}//Animal有参拷贝Animal(string n,string c,double a):name(n), color(c),\age(new double(a)){}//Animal析构函数~Animal(){delete age;}//Animal拷贝构造Animal (const Animal other):name(other.name),\color(other.color), age(new double(*other.age)){}//Animal拷贝赋值Animal operator(const Animal other){if(this ! other){name other.name;color other.color;age new double(*other.age);}return *this;} }; //封装一个狗这样类公有继承于动物类 class Dog:public Animal { //自己拓展的私有成员有指针成员腿的个数整型 int legNum) private:int *legNum;public://Dog无参拷贝Dog(){}//Dog有参拷贝Dog(int ln,string n,string c,double a):Animal(n,c,a),\legNum(new int(ln)){}//Dog析构函数~Dog(){delete legNum;}//Dog拷贝构造Dog (const Dog other):Animal(other),\legNum(new int(*other.legNum)){}//Dog拷贝赋值Dog operator(const Dog other){if(this ! other){legNum new int(*other.legNum);Animal::operator(other);}return *this;}//公有成员函数会叫void speak()void speak(){cout this : 汪汪汪…… endl;} };int main() {Dog d1;Dog d2(4,小汪,blue,2.5);Dog d3(d2);d1 d3; // d1.speak(); // d2.speak(); // d3.speak();return 0; }3试编程 要求: 以下是一个简单的比喻将多态概念与生活中的实际情况相联系 比喻动物园的讲解员和动物表演想象一下你去了一家动物园看到了许多不同种类的动物如狮子、大象、猴子等。现在动物园里有一位讲解员他会为每种动物表演做简单的介绍。 在这个场景中我们可以将动物比作是不同的类而每种动物表演则是类中的函数。 而讲解员则是一个基类他可以根据每种动物的特点和表演进行相应的介绍。 具体过程如下 定义一个基类 Animal其中有一个虛函数perform)用于在子类中实现不同的表演行为。 源代码: #include iostreamusing namespace std;//定义一个基类Animal class Animal { public:virtual void perform() 0; };//定义一个Animal的子类Lion派生类 class Lion:virtual public Animal { private:string introduction;public:Lion(string introduction):introduction(introduction){}//重写 perform()虚函数void perform() override{cout 介绍芝士狮子 introduction endl;cout 表演狮子拜天 endl;}}; //定义一个Animal的子类SnowLeopard派生类 class SnowLeopard:virtual public Animal { private:string introduction; public:SnowLeopard(string introduction):introduction(introduction){}//重写 perform()虚函数void perform() override{cout 介绍芝士雪豹 introduction endl;cout 表演与丁真珍珠去粘合国演讲。 endl;} }; //定义一个Animal的子类Elephant派生类 class Elephant:virtual public Animal { private:string introduction;public:Elephant(string introduction):introduction(introduction){}//重写 perform()虚函数void perform() override{cout 介绍芝士大象 introduction endl;cout 表演大象踢腿 endl;} };int main() {// 实例化不同的动物类Lion lion;Elephant elephant;SnowLeopard SnowLeopard;// 使用基类指针指向不同的动物对象实现多态Animal* animal1 lion;Animal* animal2 elephant;Animal* animal3 SnowLeopard;// 讲解员为每种动物表演做介绍cout 动物园讲解员开始介绍 endl;cout ------------------------ endl;cout 狮子表演 endl;animal1-perform();cout ------------------------ endl;cout 雪豹表演 endl;animal3-perform();cout ------------------------ endl;cout 大象表演 endl;animal2-perform();cout ------------------------ endl;return 0; }效果图:
http://www.zqtcl.cn/news/161040/

相关文章:

  • 厦门APP开发网站开发公司百度热搜榜单
  • 网站排名英文怎么说网页编辑器在线使用
  • 湖南做防水堵漏工程商网站网站建设编程软件
  • 网站编辑专题怎么做徐州建筑工程招投标网站
  • 英文网站建设合同招考网站开发
  • 网上商城网站 找什么做dede本地环境搭建网站
  • 网站开发遇到的问题及解决方法深圳市做网站有哪些公司
  • 自媒体网站 程序18款免费软件app下载推荐
  • 产业园门户网站建设方案瑞昌网络推广
  • 长春市网站建设动漫wordpress主题下载地址
  • 如何做专业的模板下载网站wordpress 多网址
  • 做qq头像的网站wordpress 安装 服务器 系统
  • 怎样查网站的注册地点百度小说排行榜2021
  • 网站建设中中文模板wordpress siren
  • 设计本官方网站电脑版附近室内装修公司电话
  • 服务外包网站wordpress 禁止转载
  • l礼品文化网站建设不常见的网络营销方式
  • 做网站侵权腾讯企点打不开
  • iis 网站拒绝显示此网页上海网站建设类岗位
  • 营销型网站建设推荐google关键词
  • 网站上线是前端还是后端来做如何做垂直门户网站
  • 网站建设与管理2018海尔集团网站 建设目的
  • ps做网站大小wordpress调用 php文件
  • php网站忘记后台密码江苏网页制作报价
  • 网站模板 哪个好完备的常州网站推广
  • 衡水淘宝的网站建设濮阳市城乡一体化示范区主任
  • 公司网上注册在哪个网站商洛市商南县城乡建设局网站
  • 怎么才能让网站图文展示大连网站建设设计
  • 俱乐部网站 模板seo产品是什么意思
  • 新手学做网站的教学书建造师查询官网