题目内容
请使用VC6或使用[答题]菜单打开考生文件夹proj1下的工程proj1。此工程中包括类Point、函数fun和主函数main。程序中位于每个“//ERROR ****found****”之后的一行语句有错误,请加以改正。改正后程序的输出结果应为: The point is(0,1) The point is(3,5) 注意:只修改每个“//ERROR ****found****”下的那一行,不要改动程序中的其他内容。 #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; }
查看答案
搜索结果不匹配?点我反馈
更多问题