填空题 在下列的程序的横线处填上适当的语句,使该程序的输出为12。
#include<iostream>
using namespace std;
class TestClass

public:
int a,b;
TestClass(int i,int j)

a=i;
b=j;

;
class TestClass1:public TestClass

int a;
public:
TestClass1(int x):TestClass(x,x+1)
void show()

______;//输出基类数据成员a的值?
cout<<b<<endl;

;
int main()

TestClass1 d(1);
d.show();
return 0;


  • 1、
【正确答案】 1、cout<<TestClass::a    
【答案解析】[解析] 题目中程序TestClass为基类,TestClass1为派生类,在主函数中定义TestClass1对象d(1)。根据题目要求“输出基类数据成员a的值”,基类为TestClass,利用::域运算符取其成员a的值。