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

下面这个程序的结果是#include<iostream.h>class A{private:int a;public:void seta(); int geta();};void A::seta(){ a = 1;}int A::geta(){ return a;}class B{  private:int a;public:void seta(); int geta();};void B::seta(){a = 2;}int B::geta(){return a;}class C : public A, public B{  private:int b;public:void display();};void C::display(){  int b = geta();cout << b;}void main(){  C c;c.seta();c.display();}

2024-07-09

A.1

B.2

C.随机输出1或2

D.程序有错

题目答案

试卷相关题目

最新试卷
热门试卷

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

去 App Store 免费下载 iOS 客户端