使用VC6打开考生文件夹下的工程test11_3。此工程包含一个test11_3.cpp,其中定义了类CPosition,但该类的定义都并不完整。请按要求完成下列操作,将类CPosition的定义补充完整。 (1)在类定义外完成重载的两个构造函数CPosition()和CPosition(double dx,double dy),其中前者为不带参数的构造函数,使CPosition对象的默认值为x=0,y=0,后者为带参数的构造函数,把数据成员x和y分别初始化为参数dx和dy的值。请在注释“//**1**”之后添加适当的语句。 (2)在类体中添加函数move(double ax,double ay)的定义,使得点的坐标x和y分别移动ax和ay个单位,请在注释“// **2**”之后添加适当的语句。 (3)完成函数double distance (double bx,double by)的定义,该函数返回*this和点(bx,by)的距离,请在注释“//**3**”之后添加适当的语句。 注意:除在指定的位置添加语句外,请不要改动程序中的其他语句。 源程序文件test11_3.cpp清单如下: #include<iostream.h> #include<math.h> class CPosition { public: CPosition(); CPosition(double dx,double dy); double getx(); double gety(); // ** 2 ** double distance(double bx,double by); private: double x; double y; }; // ** 1 ** { x=0;y=0; } CPosition::CPosition(double dx,double dy) { x=dx;y=dy; } double CPosition::getx() { return x; } double CPosition::gety() { return y; } double CPosition::distance(double bx,double by) { // ** 3 ** } void main() { double a,b; cout << "Input x, y position of a point:"; cin >> a >> b; CPosition psA(a,b); cout << “Input x,y position of another point:"; cin >> a >> b; cout << "The distance is " << psA.distance(a,b) <<endl; }
Psychologically there are two dangers to be guarded against in old age. One of these is undue absorption in the past. It does not do to live in memories, in regrets for the old days, or in sadness about friends who are dead. One’’s thoughts must be directed to the future, and to things about which there is something to be done. This is not always easy; one’’s own past is a gradually increasing weight. It is easy to think to oneself that one’’s emotions used to be more active than they are, and one’’s mind more keen. If this is true it should be forgotten, and if it is forgotten it will probably not be true. The other thing to be avoided is clinging tightly to youth in the hope of sucking vigor from its vitality. When your children are grown up they want to live their own lives, and if you continue to be as interested in them as you were when they were young, you are likely to become a burden to them. I do not mean that one should be without interest in them, but one’’s interest should be thoughtful and, if possible, kindly but not unduly emotional. Animals become indifferent to their young as soon as their young can look after themselves, but human beings, owing to the length of early childhood, find this difficult. I think that a successful old age is easiest for those who have strong impersonal interest involving appropriate activities. It is in this sphere mat long experience is really fruitful, and it is in this sphere that the wisdom born of experience can be exercised without being oppressive. It is no use telling grown-up children not to make mistakes, both because they will not believe you, and because mistakes are an essential part of education. But if you are one of those who are incapable of impersonal interest, you may find that your life will be empty unless you concern yourself with your children and grandchildren. In that case you must realize that while you can still render them material services, such as making them an allowance or knitting them sweaters, you must not expect that they will enjoy your company. The first paragraph of the passage suggests________.
A. modern society has made old people more fragile
B. there is still much one can do in his old age
C. in old age one should forget his past
D. in old age one should switch his thoughts to the future