namespace Wrox.ProCSarp.OOSharp
{
srtruct Vector
{
public Vector(double x,double y,double z)
{
this.x=x;
this.y=y;
this.z=z;
}public Vector(Vector rhs)
{
x=rhs.x;
y=rhs.y;
z=rhs.z;
}pubic override string ToSting()
{
return"("+x+","+y+","+z+")";
}public static Vector operator +(Vector ,Vector rhs)
{
Vecto result=new Vector(lhs);
result.x+=rhs.x;
result.y+=rhs.y;
result.z+=rhs.z;
}
}
}static
{
Vector vect1,vect2,vect3;
vect1=new Vector(3.0,3.0,1.0)
vect2=new Vectoe(2.0,-4.0,-4.0)
vect3=vect1+vect2;
Console.WriteLine("vect1="+vect1.ToString());
Console.WriteLine("vect2="+vect2.ToString());
Console.WriteLine("vect3="+vect3.ToString());
}
以上就是原程序,我要问的是这段的作用是什么
pubic override string ToSting()
{
return"("+x+","+y+","+z+")";
}+x+ 这是什么意思,希望各位前辈指点!!
谢谢
{
srtruct Vector
{
public Vector(double x,double y,double z)
{
this.x=x;
this.y=y;
this.z=z;
}public Vector(Vector rhs)
{
x=rhs.x;
y=rhs.y;
z=rhs.z;
}pubic override string ToSting()
{
return"("+x+","+y+","+z+")";
}public static Vector operator +(Vector ,Vector rhs)
{
Vecto result=new Vector(lhs);
result.x+=rhs.x;
result.y+=rhs.y;
result.z+=rhs.z;
}
}
}static
{
Vector vect1,vect2,vect3;
vect1=new Vector(3.0,3.0,1.0)
vect2=new Vectoe(2.0,-4.0,-4.0)
vect3=vect1+vect2;
Console.WriteLine("vect1="+vect1.ToString());
Console.WriteLine("vect2="+vect2.ToString());
Console.WriteLine("vect3="+vect3.ToString());
}
以上就是原程序,我要问的是这段的作用是什么
pubic override string ToSting()
{
return"("+x+","+y+","+z+")";
}+x+ 这是什么意思,希望各位前辈指点!!
谢谢
*****************************************************************************
欢迎使用CSDN论坛专用阅读器 : CSDN Reader(附全部源代码) 最新版本:20070212http://www.cnblogs.com/feiyun0112/archive/2006/09/20/509783.html
"(" + x + ..
就是合并字符串