二级二级C++全国计算机等级考试 二级C++ 笔试模拟试题(一)
题目内容

下列程序的运行结果为#include<iostream.h>class Location {protected:int X, Y;public:void SetX(int myx){X=myx;}void SetY(int myy){Y=myy;}void showxy(){cout << "X=" << X << " " << "Y=" << Y <<endl;}};class Rectangle : public Location{private:int H, W;public:void SetH(int myh){H=myh;}void SetW(int myw){W=myw;}void show(){ cout << "X=" << X << " " << "Y=" << " " << Y << " " << "H=" << H << " " << "W=" << W << endl;}};void main(){ Rectangle r1;r1.SetX (3);r1.SetY (5);r1.SetH (4);r1.SetW (6);r1.showxy();r1.show();}

2024-07-09

A.X=3 Y=5X=3 Y=5 H=4 W=6

B.X=3 Y=5X=3 Y=5 H=3 W=6

C.X=3 Y=5X=3 Y=4 H=4 W=6

D.X=3 Y=5X=3 Y=3 H=4 W=6

题目答案

试卷相关题目

最新试卷
热门试卷

长理培训客户端 资讯,试题,视频一手掌握

去 App Store 免费下载 iOS 客户端