填空题

在下面横线上填上适当的语句,完成程序。
#include <iostream>
using namespace std;
class Base

int x;
public:
Base(int i)x=i;
~Base()
;
class Derived: public Base

public:
______ //完成类Derive构造函数的定义
;
int main()

Derived Obj();
return 0;

【参考答案】

Derived(int i):Base(i){}
<上一题 目录 下一题>
热门 试题

填空题
下列程序的输出结果是______。 #include <iostream> using namespace std; class base public: int n; base(int x)n=x; virtualvoid set(int m)n=m;cout<<n<<’ ’; ; class deriveA:public base public: deriveA(int x):base(x) void set(int m) n+=m,cout<<n<<’ ’; ; class deriveB:public base public: deriveB(int x):base(x) void set(int m) n+=m; cout<<n<<’ ’; ; int main() deriveA.d1(1); deriveB.d2(3); base *pbase; pbase=&d1; pbase->set(1); pbase=&d2; pbase->set(2); return 0;
填空题
已知数组a中的元素个数为n,下列语句的作用是将下标为i的元素移动到下标为i-1的单元,其中1<i<n。例如,当n=4,a中原有数据为1,2,3,4时,则移动后a中元素变为2,3,4,4。请将语句补充完整: for(int i=0;i<n-1;i++) a[i]=a______;
相关试题
  • 下面程序的运行结果是______。 #in...