C++设计一个点类Point再设计一个矩形类矩形类使用Point类的两坐标点作为矩形对角顶点并可输出4个坐标值和面积(在线等,十分火急)
#include <iostream>
using namespace std;
class Point
{
public:
Point(int x = 0, int y = 0):x_(x), y_(y){}
int X()const{return x_;}
int Y()const{return y_;}
void X(int x){ x_ = x; }
void Y(int y){ y_ = y; }
private:
int x_;
int y_;
};
class Rectangle
{
public:
Rectangle(Point l, Point r) :ld(l), ru(r){}
int Area(){ return (ru.x - ld.x) * (ru.y - ld.y);
void Coord(){
cout<<"Point 1: "<<ld.x<<","<<ld.y<<endl;
cout<<"Point 2: "<<ru.x<<","<<rd.y<<endl;
cout<<"Point 3: "<<ru.x<<","<<ru.y<<endl;
cout<<"Point 1: "<<ld.x<<","<<ru.y<<endl;
}
private:
Point ld; //左下角的点
Point ru; //右上角的点
};
int main()
{
Point one(1, 1), two(10,10);
Rectangle r(one, two);
cout<<r.Area()<<endl;
r.Coord();
return 0;
}
请问这个哪里有问题。 fatal error C1004: unexpected end of file found
不知道哪里错了,请高手看一下。