Exercise about Shape
#include <iostream>
using namespace std;
class point
{
int x;
int y;
public :
point ()
{
x=y=;
}
point (int a,int b)
{
x=a;
y=b;
}
~point (){}
void show ()
{
cout <<"("<<x<<","<<y<<")"<<endl;
}
};
class Shape
{
private:
double longth;
double width;
public :
Shape ()
{
longth=width=;
}
Shape (double l,double w)
{
longth=l;
width=w;
cout<<"构造函数,创建Shape"<<endl;
}
~Shape()
{
cout <<"析构函数,释放Shape"<<endl;
}
double area()
{
double s;
s=longth*width;
return s;
}
void show ()
{
cout <<"面积="<<area()<<endl;
}
};
class Rectangle:public Shape
{
public :
Rectangle():Shape(,){}
Rectangle(double a,double b):Shape(a,b)
{
cout<<"创建Rectangle"<<endl;
}
void show ()
{
cout <<"面积="<<area()<<endl;
}
~Rectangle()
{
cout <<"析构函数,释放Rectangle"<<endl;
}
};
class Square:public Rectangle
{
public :
Square(double a):Rectangle(a,a)
{
cout<<"构造函数,创建Square"<<endl;
}
~Square()
{
cout <<"析构函数,释放Square"<<endl;
}
};
class Circle:public Shape
{
private :
double r;
point p;
public :
Circle(double c,point n):Shape(c,c)
{
r=c;
p=n;
cout<<"构造函数,创建Circle"<<endl;
}
~Circle()
{
cout <<"析构函数,释放Circle"<<endl;
}
double area()
{
double s;
s=3.14*r*r;
return s;
}
void show ()
{
cout <<"面积="<<area()<<endl;
}
};
int main()
{
Rectangle r(,);
r.show();
point o(,);
Circle c (4.0,o);
c.show ();
Square s();
s.show();
return ;
}
Exercise about Shape的更多相关文章
- (14)Why some people find exercise harder than others
https://www.ted.com/talks/emily_balcetis_why_some_people_find_exercise_harder_than_others/transcript ...
- OpenCASCADE Shape Location
OpenCASCADE Shape Location eryar@163.com Abstract. The TopLoc package of OpenCASCADE gives resources ...
- Drawable实战解析:Android XML shape 标签使用详解(apk瘦身,减少内存好帮手)
Android XML shape 标签使用详解 一个android开发者肯定懂得使用 xml 定义一个 Drawable,比如定义一个 rect 或者 circle 作为一个 View 的背景. ...
- Android GradientDrawable(shape标签定义) 静态使用和动态使用(圆角,渐变实现)
Android GradientDrawable使用优势: 1. 快速实现一些基本图形(线,矩形,圆,椭圆,圆环) 2. 快速实现一些圆角,渐变,阴影等效果 3. 代替图片设置为View的背景 4. ...
- AlloyRenderingEngine之Shape
写在前面 不读文章,只对代码感兴趣可以直接跳转到这里 https://github.com/AlloyTeam/AlloyGameEngine 然后star一下,多谢支持:). 游戏或者应用中,不是所 ...
- 浅谈Android样式开发之shape
引言 在Android开发中我们很多情况都是使用图片来展示相关效果,今天我就来详细介绍下Android下使用Shape来进行简单UI的开发.一方面这些是Android开发的基础,另一方面这方面的知识可 ...
- VSTO PowerPoint 代码删除Shape后再恢复出现无法再次获取的问题
做PowerPoint的VSTO插件项目,遇到个很奇怪的问题,当代码执行删除某些Shape时,没问题,但是操作Undo也就是恢复后,无法再次获取到之前删除的对象,这种情况只在Office2007中出现 ...
- android shape的使用(转)
shape用于设定形状,可以在selector,layout等里面使用,有6个子标签,各属性如下: <?xml version="1.0" encoding="ut ...
- 【Android进阶学习】shape和selector的结合使用(转)
原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 .作者信息和本声明.否则将追究法律责任.http://liangruijun.blog.51cto.com/3061169/732310 ...
随机推荐
- mysql binlog日志自动清理及手动删除
说明:当开启mysql数据库主从时,会产生大量如mysql-bin.00000* log的文件,这会大量耗费您的硬盘空间.mysql-bin.000001mysql-bin.000002mysql-b ...
- Laravel 执行流程(一)之自动加载
定位 从 public/index.php 定位到 bootstrap/autoload.php 从 bootstrap/autoload.php 定位到 vendor/autoload.php 从 ...
- linux 编译运行c文件
在ubuntu安装gcc 编辑 test.c /* Not stdio.h */ #include <unistd.h> void main() { char str[100]; /*Wr ...
- apache 压力测试ab
1.安装了apache服务器 2.进入命令行 3.模拟并发级别为100,请求数为1000个的api数据请求数量测试
- Unity编辑器中分割线拖拽的实现
GUI splitter control How can I make a GUI splitter control, similar to the splitter the console has? ...
- SQL开头quoted和ansiNULL
“QUOTED_IDENTIFIER” 当 SET QUOTED_IDENTIFIER 为 ON 时,标识符可以由双引号分隔,而文字必须由单引号分隔. 当 SET QUOTED_IDENTIFIER ...
- Elasticsearch学习之图解Elasticsearch中的_source、_all、store和index属性
转自 : https://blog.csdn.net/napoay/article/details/62233031 1. 概述 Elasticsearch中有几个关键属性容易混淆,很多人搞不清楚_s ...
- 基于VS Code创建Spring Boot项目开发REST API(一)
公司从.NET转向Java不仅仅是简单的代码变成Java,趁此机会对原有的架构和代码重构,融入新的概念和技术.目前通过前后端分离,将后端更多的微服务化.从.NET转向Java我们更多的是用Java开发 ...
- thymeleaf入门和学习
springboot框架不推荐使用jsp,一方面是兼容性的技术问题,一方面也是其前后端整合在一起,很难适合当下大规模的网站开发环境.HTML只是一种标记语言,并不具有获取model中数据的功能,所以视 ...
- django form 组件插件
创建类: class RegForms(forms.Form): account = fields.CharField( required = True, #必填字段 max_length=12, m ...