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

网站ico图标怎么做百度seo营销推广多少钱

网站ico图标怎么做,百度seo营销推广多少钱,网络建站优化科技,wordpress使用什么语言1>思维导图 2>试编程 要求: 封装一个动物的基类,类中有私有成员:姓名,颜色,指针成员年纪 再封装一个狗这样类,共有继承于动物类,自己拓展的私有成员有:指针成员:腿的个数&a…

1>思维导图

b58af2c8998243e1a9ada8f493561479.png

903795917c134cdbb12e1dd4759da70f.png

2>试编程

要求:

封装一个动物的基类,类中有私有成员:姓名,颜色,指针成员年纪

再封装一个狗这样类,共有继承于动物类,自己拓展的私有成员有:指针成员:腿的个数(整型 int count),共有成员函数:会叫:void speak()

要求:分别完成基类和派生类中的:构造函数、析构函数、拷贝构造函数、拷贝赋值函数

eg : Dog d1;

Dog d2(.....);

Dog d3(d2);

d1 = d3;

源代码:

#include <iostream>using 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 <iostream>using 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.laogonggong.com/news/15176.html

相关文章:

  • 一个网站域名多少钱鼓楼网站seo搜索引擎优化
  • 做彩妆发哪个网站浏览量高网络宣传方式有哪些
  • 答题网站怎么做经典软文范例大全
  • java高性能网站开发cpa广告联盟
  • banner在线设计网站廊坊快速排名优化
  • 哈尔滨企业做网站优化网站排名推广
  • 企业开发网站建设电子商务营销策略
  • 大淘客网站推广位怎么做google搜索入口
  • 做相册视频的网站品牌运营管理有限公司
  • 深圳专业建网站公司排行关键词优化靠谱推荐
  • 工作室网站建设要多大内存seo去哪里培训
  • 建网站的价格软文范例大全500
  • 建设部招标网 官方网站百度一下就会知道了
  • 广州高端品牌网站建设黄页网站推广
  • 网站的反链要怎么做公司推广方法有哪些
  • 有一个专门做lol同人的网站如何自己搭建一个网站
  • 建立论坛网站东莞seo整站优化
  • 石灰土做击实检测网站怎么填郑州百度推广seo
  • 有关静态网站建设的毕业论文谷歌收录查询工具
  • 台州网站开发建设市场营销推广方案模板
  • cm域名做网站电脑培训学校在哪里
  • 企业网站建设的好处武汉外包seo公司
  • 网站加载不出来是什么原因百度网盘搜索
  • 巴彦淖尔网站制作开发免费正规大数据查询平台
  • wordpress怎么导入htmlseo搜索是什么意思
  • 做网站订单关键词查询网
  • sharepoint 网站开发简单网页制作成品免费
  • 威海网站建设深圳宝安seo外包
  • 茶叶网站模板下载网站百度收录突然消失了
  • 做网站用别人图片文章会侵权吗指数网站