着急中!!求Visual C++高手来帮帮我 看看

来源:百度知道 编辑:UC知道 时间:2024/09/26 20:09:29
都是只改*****found******下一行有错
(1)改错:要求输出为
The point is (0,1)
The point is (3,5)

#include <iostream>
using namespace std;

class Point {
public:
// ERROR *********found*********
Point(int x = 0, int y)
: x_(x), y_(y) { }

// ERROR *********found*********
void move(int xOff, int yOff) const
{
x_ += xOff;
y_ += yOff;
}

void print() const
{
cout << "The point is (" << x_ << ',' << y_ << ')' << endl;
}
private:
int x_, y_;
};

void fun(Point* p)
{
// ERROR *********found*********
p.print();
}

int main()
{
Point p1, p2(2,1);
p1.print();
p2.move(1,4);
fun(&p2);

return 0;
}
(2)要求输出的结果为
Upper left=(1,8), down right=(5,2), area=24

#include<ios

1
Point(int x = 0, int y=1)
2
void move(int xOff, int yOff) const const去掉
3
p.print();改为p->print();

1
Rectangle(double x1, y1; double x2, y2){ 改为:
Rectangle(double x1,double y1 ,double x2,double y2){
2
void show(Rectangle r)const{ 改为
void show(Rectangle r){
3
cout<<r.x1<<" , "<<r.y1<<"), down right=("<<r.x2<<" , "<<r.y2; 改为
cout<<r.getX1()<<" , "<<r.getY1()<<"), down right=("<<r.getX2()<<" , "<<r.getY2();