对象数组
rtK100150满分答卷(100150.com)-青少年编程等级考试及竞赛题库#include <iostream>
rtK100150满分答卷(100150.com)-青少年编程等级考试及竞赛题库using namespace std;
rtK100150满分答卷(100150.com)-青少年编程等级考试及竞赛题库class Location
rtK100150满分答卷(100150.com)-青少年编程等级考试及竞赛题库{
rtK100150满分答卷(100150.com)-青少年编程等级考试及竞赛题库int x,y;
rtK100150满分答卷(100150.com)-青少年编程等级考试及竞赛题库public:
rtK100150满分答卷(100150.com)-青少年编程等级考试及竞赛题库Location();
rtK100150满分答卷(100150.com)-青少年编程等级考试及竞赛题库Location(int xx,int yy);
rtK100150满分答卷(100150.com)-青少年编程等级考试及竞赛题库~Location();
rtK100150满分答卷(100150.com)-青少年编程等级考试及竞赛题库void Move(int m,int n);
rtK100150满分答卷(100150.com)-青少年编程等级考试及竞赛题库int GetX(){return x;}
rtK100150满分答卷(100150.com)-青少年编程等级考试及竞赛题库int GetY(){return y;}
rtK100150满分答卷(100150.com)-青少年编程等级考试及竞赛题库};
rtK100150满分答卷(100150.com)-青少年编程等级考试及竞赛题库Location::Location()
rtK100150满分答卷(100150.com)-青少年编程等级考试及竞赛题库{
rtK100150满分答卷(100150.com)-青少年编程等级考试及竞赛题库x=y=0;
rtK100150满分答卷(100150.com)-青少年编程等级考试及竞赛题库cout << "Default Constructor called." << endl;
rtK100150满分答卷(100150.com)-青少年编程等级考试及竞赛题库}
rtK100150满分答卷(100150.com)-青少年编程等级考试及竞赛题库Location::Location(int xx,int yy):x(xx),y(yy)
rtK100150满分答卷(100150.com)-青少年编程等级考试及竞赛题库{
rtK100150满分答卷(100150.com)-青少年编程等级考试及竞赛题库cout << "Construcator called." << endl;
rtK100150满分答卷(100150.com)-青少年编程等级考试及竞赛题库}
rtK100150满分答卷(100150.com)-青少年编程等级考试及竞赛题库Location::~Location()
rtK100150满分答卷(100150.com)-青少年编程等级考试及竞赛题库{
rtK100150满分答卷(100150.com)-青少年编程等级考试及竞赛题库cout << "Destructor called." << endl;
rtK100150满分答卷(100150.com)-青少年编程等级考试及竞赛题库}
rtK100150满分答卷(100150.com)-青少年编程等级考试及竞赛题库void Location::Move(int m,int n)
rtK100150满分答卷(100150.com)-青少年编程等级考试及竞赛题库{
rtK100150满分答卷(100150.com)-青少年编程等级考试及竞赛题库x = m;
rtK100150满分答卷(100150.com)-青少年编程等级考试及竞赛题库y = n;
rtK100150满分答卷(100150.com)-青少年编程等级考试及竞赛题库}
rtK100150满分答卷(100150.com)-青少年编程等级考试及竞赛题库int main()
rtK100150满分答卷(100150.com)-青少年编程等级考试及竞赛题库{
rtK100150满分答卷(100150.com)-青少年编程等级考试及竞赛题库Location A[2];
rtK100150满分答卷(100150.com)-青少年编程等级考试及竞赛题库for(int i = 0; i < 2; i++)
rtK100150满分答卷(100150.com)-青少年编程等级考试及竞赛题库cout << A[i].GetX() << "," << A[i].GetY() << endl; //0,0\n0,0
rtK100150满分答卷(100150.com)-青少年编程等级考试及竞赛题库Location B[2] = {Location(1,2), Location(3,4)};
rtK100150满分答卷(100150.com)-青少年编程等级考试及竞赛题库for (int i = 0; i < 2; i++)
rtK100150满分答卷(100150.com)-青少年编程等级考试及竞赛题库cout << B[i].GetX() << "," << B[i].GetY() << endl; //1,2\n3,4
rtK100150满分答卷(100150.com)-青少年编程等级考试及竞赛题库for(int i = 0; I < 2; i++)
rtK100150满分答卷(100150.com)-青少年编程等级考试及竞赛题库A[i].Move(i + 10, i + 20);
rtK100150满分答卷(100150.com)-青少年编程等级考试及竞赛题库for(int i = 0; i < 2; i++)
rtK100150满分答卷(100150.com)-青少年编程等级考试及竞赛题库cout << A[i].GetX() << "," << A[i].GetY() << endl;
rtK100150满分答卷(100150.com)-青少年编程等级考试及竞赛题库//A[2][2] = {{10,20}, {11,21}}
rtK100150满分答卷(100150.com)-青少年编程等级考试及竞赛题库return 0;
rtK100150满分答卷(100150.com)-青少年编程等级考试及竞赛题库}
rtK100150满分答卷(100150.com)-青少年编程等级考试及竞赛题库程序运行结果:
rtK100150满分答卷(100150.com)-青少年编程等级考试及竞赛题库Default Constructor called.
rtK100150满分答卷(100150.com)-青少年编程等级考试及竞赛题库Default Constructor called.
rtK100150满分答卷(100150.com)-青少年编程等级考试及竞赛题库0,0
rtK100150满分答卷(100150.com)-青少年编程等级考试及竞赛题库0,0
rtK100150满分答卷(100150.com)-青少年编程等级考试及竞赛题库Construcator called.
rtK100150满分答卷(100150.com)-青少年编程等级考试及竞赛题库Construcator called.
rtK100150满分答卷(100150.com)-青少年编程等级考试及竞赛题库1,2
rtK100150满分答卷(100150.com)-青少年编程等级考试及竞赛题库3,4
rtK100150满分答卷(100150.com)-青少年编程等级考试及竞赛题库10,
rtK100150满分答卷(100150.com)-青少年编程等级考试及竞赛题库20
rtK100150满分答卷(100150.com)-青少年编程等级考试及竞赛题库11,21
rtK100150满分答卷(100150.com)-青少年编程等级考试及竞赛题库Destructor called.
rtK100150满分答卷(100150.com)-青少年编程等级考试及竞赛题库Destructor called.
rtK100150满分答卷(100150.com)-青少年编程等级考试及竞赛题库Destructor called.
rtK100150满分答卷(100150.com)-青少年编程等级考试及竞赛题库Destructor called.