填空题
有如下程序: #include<iostream> using namespace std; class A{ public: A(){cout<<“A”;} ~A(){cout<<“A”;) }; class B{ A a; public, B(){cout<<“B”;} ~B(){cout<<“B”;} }; int main(){ B b; return 0; } 程序的输出结果是______。
【参考答案】
ABBA。
点击查看答案&解析
<上一题
目录
下一题>
热门
试题
填空题
请将下列栈类Stack补充完整。class Stack{private:intpList[100] int数组,用于存放栈的元素inttop; 栈顶元素(数组下标)public:Stack();top(0){}void Push(const int &item); 新元素item压入栈int Pop(void); 将栈顶元素弹出栈};void Stack::Push(const int&item){if(top==99) 如果栈满,程序终止exit(1)top++; 栈顶指针增1______;}int Stack::Pop(){if(top(0) 如果栈空,程序终止exit(1);return pList[top--];}
点击查看答案
填空题
如下程序声明了一个使用两个通用数据类型的模板类dataClass,其中构造函数用于初始化两个数据成员,成员函数show用于输出两个数据成员的数值。#include<iostream>using namespace std;______T1;T2;public;dataClass(T1 aT2 b){i=a;j=b;}void show(){cout<<i<<“,”<<j<<‘\n’;}};int main(){dataClass<int,double>obl<10,0.23>;dataClass(char,char*)ob2(‘X’,”my data”);ob1.show();ob2.show();return 0;}请将程序补充完整,使程序在运行时输出:10,0.23X,my data
点击查看答案&解析
相关试题
在下面程序的横线处填上适当的内容,使程序...