zoukankan
html css js c++ java
抽象类
//
抽象类
//
Visual Studio 允许定义抽象类.抽象类是为了派生类而定义接口的一个类.抽象类从本质上说是抽象的,
//
因为在抽象类基础上建立的所有类都提供了一定的方法和属性.您不能在抽象类中创建对象----只能利用
//
它们来派生新的类
//
抽象类在c#中用abstract 关键字来声明.必须提供的方法与属性用abstract来表明.
//
在vb.net中用MustInherit , MustOverride .
using
System;
namespace
FlashCards
{
/**/
///
<summary>
///
Shape 的摘要说明。
///
</summary>
public
abstract
class
Shape
//
形状
{
public
Shape()
{
//
//
TODO: 在此处添加构造函数逻辑
//
}
public
abstract
float
Top
{
get
;
set
;
}
public
abstract
float
Left
{
get
;
set
;
}
public
abstract
float
Area();
public
abstract
float
Perimeter();
}
//
覆盖抽象类成员的每一个成员定义都需要 Overrides(vb.net) 或 override(c#) 关键字.
public
class
CirCle:Shape
{
float
fxCenter,fyCenter,fRadius;
public
CirCle()
{
fxCenter
=
0
;
fyCenter
=
0
;
fRadius
=
0
;
}
public
override
float
Top
{
get
{
return
fxCenter
-
fRadius;}
//
fx
set
{fxCenter
=
value
+
fRadius;}
}
public
override
float
Left
{
get
{
return
fyCenter
-
fRadius;}
//
fy
set
{fyCenter
=
value
+
fRadius;}
}
public
override
float
Area()
{
return
(
float
)(
2
*
System.Math.PI
*
Math.Pow((
double
)fRadius,
2
));
}
public
override
float
Perimeter()
{
return
2
*
fRadius
*
(
float
)System.Math.PI;
}
public
float
Radius
{
get
{
return
fRadius;}
set
{fRadius
=
value;}
}
public
virtual
void
Center(
float
x,
float
y)
{
fxCenter
=
x;
fyCenter
=
y;
}
}
}
查看全文
相关阅读:
mailing list的原理
关于结构体的使用
c++ template
IDA逆向
重定向 301 302
linux信号
cmake编译选项
mongodb超时
普通java工程的resources目录寻址
Vue基础---->VueJS的使用(二)
原文地址:https://www.cnblogs.com/furenjun/p/318423.html
最新文章
Scalaz(54)- scalaz-stream: 函数式多线程编程模式-Free Streaming Programming Model
Scalaz(53)- scalaz-stream: 程序运算器-application scenario
Scalaz(52)- scalaz-stream: 并行运算-parallel processing concurrently by merging
Scalaz(51)- scalaz-stream: 资源使用安全-Resource Safety
Scalaz(50)- scalaz-stream: 安全的无穷运算-running infinite stream freely
Scalaz(49)- scalaz-stream: 深入了解-Sink/Channel
Scalaz(48)- scalaz-stream: 深入了解-Transducer: Process1-tee-wye
Scalaz(47)- scalaz-stream: 深入了解-Source
Scalaz(46)- scalaz-stream 基础介绍
cookie、 sessionStorage 、localStorage之间的区别和使用
热门文章
js ——算法
easyui numberbox不可编辑
算法——js(Fibonacci数列)
算法——猴子分桃
css——子代与后代选择器
表单重置reset
数字转中文,大写,金额
easyui 中重复加载两次url
常用的正则验证
virtualbox mac-debian共享文件夹
Copyright © 2011-2022 走看看