C++学习:继承有关问题

C++学习:继承问题
题目:把定义平面直角坐标系上的一个点的类CPoint作为基类,派生出描述一条直线的类CLine,再派生出一个矩形类CRect。要求成员函数能求出两点间的距离,矩形的周长和面积等。设计一个测试程序,并构造完整的程序。
下面程序报错:
C/C++ code
#include <iostream.h>
#include <math.h>

class CPoint
{
private:
    double nPosX,nPosY;

public:
    CPoint(double x, double y)
    {
        nPosX = x;
        nPosY = y;
    }
    void ShowPos()
    {
        cout<<"当前位置: x = "<<nPosX<<" , y = "<<nPosY<<endl;
    }
};
class CLine: public CPoint
{
private:
    double nLength;

public:
    CLine()
    {
        nLength = 0;
    }
    double LineLength(double x1, double y1, double x2, double y2)
    {
        nLength = sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));
        return nLength;
    }
};

class CRect: public CPoint
{
private:
    double dWideL;
    double dHeightL;

public:
    CRect()
    {
        dWideL = 0;
        dheightL = 0;
    }
    double RectSL(double WideL, double HeightL)
    {
        return 2*(WideL + HeightL);
    }
};

int main()
{
    CPoint LU(0.0,1.0);
    CPoint LD(0.0,0.0);
    CPoint RU(1.0,1.0);
    CPoint RD(1.0,0.0);

    CLine Wide;
    CLine Length;

    CRect One;

    double AWide;
    double ALength;
    double P;

    AWide = Wide.LineLength(0.0,1.0,1.0,1.0);
    ALength = Length.LineLength(0.0,1.0,0.0,0.0);

    P = One.RectSL(AWide, ALength);

    return 0;
}

错误信息为: error C2512: 'CPoint' : no appropriate default constructor available

------解决方案--------------------
子类构造时候需要先调用父类的构造函数,因此子类的构造函数中需要告知如何构造父类,如果父类具有默认构造函数,则可以不写
------解决方案--------------------
1楼正解
Cline的构造函数可以这么写
CLine(double x, double y):CPoint(x,y)
{
nPosX = x;
nPosY = y;
}