class Point
{
public double x, y;
public Point()
{
this.x = 0;
this.y = 0;
} public Point(double x, double y)
{
this.x = x;
this.y = y;
} public static double Distance(Point a, Point b)
{
double xdf = a.x - b.y;
double ydf = a.y - b.y;
return Math.Sqrt(xdf*xdf+ydf*ydf);
}
请问一下上面这段代码里的是什么意思:
public Point()
{
this.x = 0;
this.y = 0;
} public Point(double x, double y)
{
this.x = x;
this.y = y;
}
麻烦大家给我解释一下,我是初学.
{
public double x, y;
public Point()
{
this.x = 0;
this.y = 0;
} public Point(double x, double y)
{
this.x = x;
this.y = y;
} public static double Distance(Point a, Point b)
{
double xdf = a.x - b.y;
double ydf = a.y - b.y;
return Math.Sqrt(xdf*xdf+ydf*ydf);
}
请问一下上面这段代码里的是什么意思:
public Point()
{
this.x = 0;
this.y = 0;
} public Point(double x, double y)
{
this.x = x;
this.y = y;
}
麻烦大家给我解释一下,我是初学.
解决方案 »
- 如何去除字符串中的非法字符
- 求高手帮忙看下下面的方法是干嘛的,顺便每一行都标上注释,50分辛苦费双手奉上
- c#组件和控件的区别,什么时候用组件?什么时候该用控件呢
- 不是很明白WinForm的Application.Run,请专家帮忙
- .dll
- 如何在WIN2003终端里修改终端的刷新率.
- HttpWebRequest和WebBrowser共享session
- 如何 实现如彩票开奖数据折线图这样的图标?
- textbox 绑定到 app.config的问题
- 关于Windows Service的一个古怪的错误 1+1!=2???
- <web.config>设置?(顶者有分)
- 如何设置combobox边框颜色
Point a = new Point(1,2) 就执行下面这个
public Point()
{
this.x = 0; //让类的成员标量x=0
this.y = 0; //让类的成员标量y=0
} public Point(double x, double y)
{
this.x = x; //让类的成员标量x等于传入的参数double x
this.y = y; //让类的成员标量y等于传入的参数double y }
public Point() //这个是无参方法
{
this.x = 0;
this.y = 0;
} public Point(double x, double y) //这个是有参方法
{
this.x = x;
this.y = y;
}
大致是这样Point point1=new Point();
调用第一个Point point2=new Point(3.0,5.0);
实例化对象时调用第二个一个是有参数,一个是无参数无参数的是默认的构造方法,根据需要选择