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

软件下载大全网站云南网站建设快速优化

软件下载大全网站,云南网站建设快速优化,王爷设计与网站建设基础有感,企业网站二级域名好做吗实现一个图形类(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.mmbaike.com/news/88830.html

相关文章:

  • 教育公司网站建设方案seo数据是什么
  • 备案成功的网站百度广告推广平台
  • 网站建设方案书模板下载官网seo是什么意思
  • wap网站域名成品网站源码在线看
  • 深圳网站建设 百业su搜索引擎优化
  • 网站技术策划内容张家口网站seo
  • 订单系统单页面网站怎么做什么叫优化
  • 茌平做网站推广seo策略是什么意思
  • app开发公司比较好seo优化几个关键词
  • 怎样拥有自己的网站国内产女装一线二线品牌知乎
  • 深圳自适应网站的公司b站推广网站入口mmm
  • 主机做网站工具靠谱的代运营公司
  • php动态网站开发教程如何建网站
  • 网站建设销售话术开场白房产网站建设
  • dede网站乱码steam交易链接在哪里
  • 东莞凤岗网站建设制作如何优化网络连接
  • 建设学校网站的操作流程具体中央电视台一套广告价目表
  • 天河公司网站建设公司苏州seo门户网
  • 南通网站建设祥云seo线下培训课程
  • 网站建设公司怎么做业务独立站seo推广
  • 网站服务器费用明细美国搜索引擎浏览器
  • 网站模板免费推荐专业seo外包
  • wordpress 如何备份数据库结构怎么优化网站关键词排名
  • 云网站制作的流程百度快照投诉中心人工电话
  • 网站虚拟主机租用百度关键词权重查询
  • 驾校报名网站怎么做seo优化在哪里学
  • 网站建设服务费税点全网络品牌推广
  • wordpress网站logo没显示互联网营销推广公司
  • 一条龙网站建设哪家专业怎么查看网站的友情链接
  • 鄱阳做网站seo优化一般包括