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

南昌做网站市场报价佛山百度seo点击软件

南昌做网站市场报价,佛山百度seo点击软件,商城网站的设计风格,兴义做网站的公司实现一个图形类(Shape),包含受保护成员属性:周长、面积, 公共成员函数:特殊成员函数书写 定义一个圆形类(Circle),继承自图形类,包含私有属性:半…

实现一个图形类(Shape),包含受保护成员属性:周长、面积,

公共成员函数:特殊成员函数书写

定义一个圆形类(Circle),继承自图形类,包含私有属性:半径

公共成员函数:特殊成员函数、以及获取周长、获取面积函数

定义一个矩形类(Rect),继承自图形类,包含私有属性:长度、宽度

公共成员函数:特殊成员函数、以及获取周长、获取面积函数

在主函数中,分别实例化圆形类对象以及矩形类对象,并测试相关的成员函数。

#include <iostream>using namespace std;
class Shape
{
protected:double round;double area;
public:Shape(){cout<<"无参构造"<<endl;}Shape(double r,double a):round(r),area(a){cout<<"有参构造"<<endl;}~Shape(){cout<<"析构函数"<<endl;}Shape(const Shape &other):round(other.round),area(other.area){cout<<"拷贝构造"<<endl;}Shape & operator=(const Shape &other){this->area=other.area;this->round=other.round;cout<<"拷贝赋值"<<endl;return *this;}Shape & operator=(Shape &&other){this->area=other.area;this->round=other.round;cout<<"移动赋值"<<endl;return *this;}};
class Circle:public Shape
{
private:double bj;
public:Circle() {}Circle(double r):bj(r){cout<<"有参构造"<<endl;}~Circle(){cout<<"析构函数"<<endl;}Circle(const Circle &other):Shape(other.round,other.area),bj(other.bj){cout<<"拷贝构造"<<endl;}Circle & operator=(const Circle &other){this->area=other.area;this->round=other.round;this->bj=other.bj;cout<<"拷贝赋值"<<endl;return *this;}Circle & operator=(Circle &&other){this->area=other.area;this->round=other.round;this->bj=other.bj;cout<<"移动赋值"<<endl;return *this;}void zc(){this->round=this->bj*2*(3.14);cout<<"周长="<<round<<endl;}void mj(){this->area=this->bj*this->bj*(3.14);cout<<"面积="<<area<<endl;}void show(){cout<<"周长="<<round<<endl;cout<<"面积="<<area<<endl;}
};
class Rect:public Shape
{
private:double hight;double wight;
public:Rect() {}Rect(double h,double w):hight(h),wight(w){cout<<"有参构造"<<endl;}~Rect(){cout<<"析构函数"<<endl;}Rect(const Rect &other):Shape(other.round,other.area),hight(other.hight),wight(other.wight){cout<<"拷贝构造"<<endl;}Rect & operator=(const Rect &other){this->area=other.area;this->round=other.round;this->hight=other.hight;this->wight=other.wight;cout<<"拷贝赋值"<<endl;return *this;}Rect & operator=(Rect &&other){this->area=other.area;this->round=other.round;this->hight=other.hight;this->wight=other.wight;cout<<"移动赋值"<<endl;return *this;}void zc(){this->round=(this->hight+this->wight)*2;cout<<"周长="<<round<<endl;}void mj(){this->area=this->hight*this->wight;cout<<"面积="<<area<<endl;}void show(){cout<<"周长="<<round<<endl;cout<<"面积="<<area<<endl;}
};
int main()
{Circle c1(10);c1.zc();c1.mj();Circle c2(c1);c2.show();Circle c3;c3=c1;c3.show();Circle c4;c4=move(c3);c3.show();c4.show();cout<<"******************************************"<<endl;Rect r1(10,5);r1.mj();r1.zc();Rect r2=r1;r2.show();Rect r3;r3=r1;r3.show();return 0;
}

http://www.mmbaike.com/news/50445.html

相关文章:

  • 凡科网做网站怎样阿里云网站搭建
  • 福州微信营销网站建设企业网站的搜索引擎推广与优化
  • 娱乐网站设计多少行业镇江推广公司
  • 还有什么网站可以做面包车拉货哈尔滨seo推广
  • 深圳视频制作公司微博seo营销
  • 做淘客网站要备案公司培训
  • 专门做微信公众号的网站vue seo优化
  • 国内最最早做虚拟货币的网站怎么弄一个自己的网站
  • 写一个wordpress下载插件seo是做什么工作内容
  • 台州网站公司seo课程培训
  • 怎么做短链接网站seo查询平台
  • 网站透明导航代码网络推广属于什么专业
  • 做的最好的手机网站seo网站优化多少钱
  • pc网站怎么做适配今日军事新闻报道
  • 郑州做网站的外包公司有哪些11月将现新冠感染高峰
  • 用vs怎么做网站的导航深圳网站关键词
  • 衢州做网站 thinknew企业文化标语经典
  • 清溪镇做网站北京朝阳区优化
  • 做网站什么字体百度的官方网站
  • 合肥网站网页设计seo管家
  • 网站域名变更后怎样操作it培训机构排名
  • 哪些做直播卖食品的网站精准引流推广公司
  • 制作ppt的软件有哪些网站seo报价
  • 有什么做木工的网站长治seo
  • 网站要怎样做才能获得市场份额长沙互联网推广公司
  • 做网站语言学什么网站模板之家免费下载
  • 房地产中介网站建设专业网站制作
  • 那个企业网站是用vue做的关键词抓取工具都有哪些
  • 吴江住房和城乡建设局网站百度上广告怎么搞上去的
  • 长沙市网站制作公司如何做好营销推广