在二维直角坐标系上,定义一个点类Point,
在二维直角坐标系上,定义一个点类Point,由类Point派生定义描述一个线段的类Line。要求Line类的成员函数能计算线段的长度。设计一个主函数充分测试所定义的类。C...
在二维直角坐标系上,定义一个点类Point,由类Point派生定义描述一个线段的类Line。要求Line类的成员函数能计算线段的长度。设计一个主函数充分测试所定义的类。
C++题目,我是真的不会做啊,大家帮帮忙啊!!! 展开
C++题目,我是真的不会做啊,大家帮帮忙啊!!! 展开
1个回答
展开全部
In a two-dimensional Cartesian coordinate system, creating a point class, the class name is Point, class Line is derived from the class Point and then to implement a segment of line. and a method function of the class Line can calculate the length of line. Then design a main function test all class.
public class Point
{
int x;
int y;
int z;
}
public class Line:Point
{
public int getLong()
{
return x+y+z;
}
}
public class main()
{
static main()
{
line objline=new line;
objline.x=1;
objline.y=2;
objline.z=3;
printf("long",objline.getlong);
}
}
public class Point
{
int x;
int y;
int z;
}
public class Line:Point
{
public int getLong()
{
return x+y+z;
}
}
public class main()
{
static main()
{
line objline=new line;
objline.x=1;
objline.y=2;
objline.z=3;
printf("long",objline.getlong);
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询