谁帮我解一下这个c++程序问题?

2024-11-21 17:59:06
推荐回答(1个)
回答1:

#include
using namespace std;

class Point
{
public:
Point();
Point(double,double);
void getlocation(double &,double &);
private:
double x,y;
};

Point::Point()
{
x=0;
y=0;
}

Point::Point(double a,double b)
{
x=a;
y=b;
}

void Point::getlocation(double &a,double &b)
{
a=x;
b=y;
}

class CLine :public Point
{
public:
CLine(double,double);
void getlocation1(double &,double &);
private:
double x1,y1;
};

CLine::CLine(double a,double b)
{
x1=a;
y1=b;
}

void CLine::getlocation1(double &a,double &b)
{
a=x1;
b=y1;
}

int main()
{
double a,b;
Point tmp1(1,2);
CLine tmp2(3,4);
tmp1.getlocation(a,b);
cout< tmp2.getlocation1(a,b);
cout<}