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

软件下载大全网站做app推广去哪找商家

软件下载大全网站,做app推广去哪找商家,绿植网站怎么做,电力建设官方网站实现一个图形类(Shape) ,包含受保护成员属性:周长、面积, 公共成员函数:特殊成员函数书写 定义一个圆形类(Circle) ,继承自图形类,包含私有属性:半径 公共成员函数:特殊成员函数…

实现一个图形类(Shape) ,包含受保护成员属性:周长、面积,
                        公共成员函数:特殊成员函数书写
定义一个圆形类(Circle) ,继承自图形类,包含私有属性:半径
                        公共成员函数:特殊成员函数、以及获取周长、获取面积函数
定义一个矩形类(Rect),继承自图形类,包含私有属性:长度、宽度
                        公共成员函数:特殊成员函数、以及获取周长、获取面积函数
在主函数中,分别实例化圆形类对象以及矩形类对象,并测试相关的成员函数。

#include <iostream>
#define pai 3.14159
using namespace std;
//图形类
class Shape
{
protected:double cir;   //周长double area;   //面积
public://无参构造函数Shape(){}//有参构造函数Shape(double a,double b):cir(a),area(b){cout<<"Shape有参构造函数"<<endl;}//析构函数~Shape(){cout<<"Shape析构函数"<<endl;}//拷贝构造函数Shape(const Shape &other):cir(other.cir),area(other.area){cout<<"拷贝构造函数"<<endl;}//定义拷贝赋值函数Shape &operator=(const Shape &other){this->cir =other.cir;this->area =other.area;return *this;}//移动赋值函数Shape &operator=(Shape &&other){this->cir =other.cir;this->area =other.area;return *this;}};//圆形类,继承图形类
class Circle:public Shape
{
private:double r;  //半径
public://无参构造函数Circle(){}//有参构造函数Circle(double c):r(c){cout<<"Circle有参构造函数"<<endl;}//析构函数~Circle(){cout<<"Circle析构函数"<<endl;}//拷贝构造函数Circle(const Circle &other):r(other.r){cout<<"拷贝构造函数"<<endl;}//定义拷贝赋值函数Circle &operator=(const Circle &other){this->r =other.r;return *this;}//移动赋值函数Circle &operator=(Circle &&other){this->r =other.r;return *this;}//获取周长double get_len(){cir = 2 * r * pai;return cir;}//获取面积double get_area(){area = pai * r * r;return area;}};//定义一个矩形类,继承自图形类
class Rect:public Shape
{
private:double lenth;  //长度double width;  //宽度
public://无参构造函数Rect(){}//有参构造函数Rect(double l,double w):lenth(l),width(w){cout<<"Rect有参构造函数"<<endl;}//析构函数~Rect(){cout<<"Rect析构函数"<<endl;}//拷贝构造函数Rect(const Rect &other):lenth(other.lenth),width(other.width){cout<<"拷贝构造函数"<<endl;}//定义拷贝赋值函数Rect &operator=(const Rect &other){this->width =other.width;this->lenth = other.lenth;return *this;}//移动赋值函数Rect &operator=(Rect &&other){this->width =other.width;this->lenth = other.lenth;return *this;}//获取周长double get_len(){cir = (width+lenth)*2;return cir;}//获取面积double get_area(){area = lenth * width;return area;}};int main()
{Circle c1(5.3);cout<<"周长是"<<c1.get_len()<<"   面积是:"<<c1.get_area()<<endl;Circle c2(c1);cout<<"周长是"<<c2.get_len()<<"   面积是:"<<c2.get_area()<<endl;Circle c3 = (2);cout<<"周长是"<<c3.get_len()<<"   面积是:"<<c3.get_area()<<endl;cout<<"*********************************************************"<<endl;Rect r1(2.4,9.9);cout<<"Rect周长是"<<r1.get_len()<<"   Rect面积是:"<<r1.get_area()<<endl;Rect r2(r1);cout<<"Rect周长是"<<r2.get_len()<<"   Rect面积是:"<<r2.get_area()<<endl;Rect r3(1.2,3.4);cout<<"Rect周长是"<<r3.get_len()<<"   Rect面积是:"<<r3.get_area()<<endl;Rect r4 = r3;cout<<"Rect周长是"<<r4.get_len()<<"   Rect面积是:"<<r4.get_area()<<endl;return 0;
}

http://www.15wanjia.com/news/6317.html

相关文章:

  • 常平东莞网站建设免费好用的网站
  • 网站源代码安装全网推广网站
  • 青岛网站建设最便宜seo能干一辈子吗
  • wordpress更改seo搜索引擎优化期末及答案
  • 网站一个页面多少钱网站优化外包价格
  • 自己做网站挂广告海外广告投放公司
  • 卡盟做网站it培训班
  • 成品网站超市源码免费的外链网站
  • 合肥做网站建设公司品牌推广策略怎么写
  • 新疆建设网站统计报直报平台seo1新地址在哪里
  • 网站收益今日资讯最新消息
  • 云南网站建设哪家强百度一下手机版首页
  • 付网站建设费用会计分录网络营销策略包括哪些
  • dede 网站名称 空的项目推广计划书
  • 网站怎么正确的做内链接谷歌推广外包
  • 网站程序开发技术友情链接网站免费
  • python做爬虫和做网站军事新闻最新
  • 电子商务网站建设与管理 pdf怎么建设自己的网站
  • 怎样在门户网站做 推广南宁seo服务优化
  • 建站技术论坛百度权重高的发帖网站
  • 烟台专业做网站百度关键词推广多少钱
  • 自己制作的网站怎么做分页揭阳seo推广公司
  • 网站建设合同有效期网络优化seo薪酬
  • 网站301了不知道在哪做的交换友情链接的意义是什么
  • 政府网站保障好 建设好深圳网站设计专家乐云seo
  • 网站建设属于什么最新行业动态
  • 修改wordpress ftp端口上海怎么做seo推广
  • 公司做网站推广要注意什么企业网站设计
  • 开网上授课的网站应该怎么做360上网安全导航
  • 王烨森国内seo公司哪家最好