学习型 ASP/PHP/ASP.NET 主机 30元/年全能 ASP/PHP/ASP.NET 主机,支持月付专业 MSSQL 数据库空间,支持月付专业 MySQL 数据库空间,支持月付
发新话题
打印

求救,在VC下编译出错。3处错误

求救,在VC下编译出错。3处错误

#include<math.h>
#include<iostream.h>
class point
{
private:
     int x,y;
public:
    point (int xx=0,int yy=0)
    {
        x=xx;
        y=yy;
    }
    point (point &p);

    int getx()
    {
        return x;
    }
    int gety()
    {
        return y;
    }
}
point::point(point &p)
{
    x=p.x;
    y=p.y ;
    cout<<p.x;
    cout<<"point 拷贝构造函数被调用"<<endl;
}
class distance
{
private :
    point p1,p2;
    double dist;
public :
    distance(point xp1,point xp2);
    double getdis()
    {
        return dist;
    }
};
    distance::distance(point xp1,point xp2):p1(xp1),p2(xp2)
    {
            cout<<"distance 拷贝构造函数被调用"<<endl;
            double x=double(p1.getx()-p2.getx());
            double y=double(p1.gety()-p2.gety());
            dist =sqrt(x*x+y*y);
    }
void main()
{
    point myp1(1,1),myp2(4,5);

}

TOP

#include<math.h>
#include<iostream.h>
class point
{
private:
     int x,y;
public:
    point(int xx=0,int yy=0)
    {
        x=xx;
        y=yy;
    }
    point(point &p);

    int getx()
    {
        return x;
    }
    int gety()
    {
        return y;
    }
};
point::point(point &p)
{
    x=p.x;
    y=p.y ;
    cout<<p.x;
    cout<<"point 拷贝构造函数被调用"<<endl;
}
class distance
{
private :
    point p1,p2;
    double dist;
public :
    distance(point xp1,point xp2);
    double getdis()
    {
        return dist;
    }
};
    distance::distance(point xp1,point xp2):p1(xp1),p2(xp2)
    {
            cout<<"distance 拷贝构造函数被调用"<<endl;
            double x=double(p1.getx()-p2.getx());
            double y=double(p1.gety()-p2.gety());
            dist =sqrt(x*x+y*y);
    }
void main()
{
    point myp1(1,1),myp2(myp1);

}
学习需要安静。。海盗要重新来过。。

TOP

谢谢,我知道为什么错了

TOP

发新话题