填空题
在下面横线上填上适当的语句,完成程序。 #include<iostream> using namespace std; class Base { int x; public: Base(int i) { x=i; } ~Base() { } }; class Derived: public Base { public:
【14】
//完成类Derive 构造函数的定义 }; int main() { Derived Obj(); return 0; }
【参考答案】
Derived(int i):Base (i) {}
点击查看答案
<上一题
目录
下一题>
热门
试题
填空题
下列程序的输出结果是 【15】 。#include <iostream>using namespace std;class base {public:int n;base(int x) { n=x;}virtual void 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 derive B: public base {public:derive B(int x):base(x) {}void set(int m) { n+=m; cout<<n<<’ ’;}};int main(){derive A, d1(1);derive B, d2(3);base *pbase;pbase=&d1;pbase->set(1);pbase=&d2;phase->set(2);return 0;}
点击查看答案
填空题
有如下程序:#include<iostream.h>void main(){int x=2,y=3,a,b,c,d;a=(x++>=--y);b=(x==++y);c=(x--!=y);d=(++x>y--);Cout<<a<<b<<c<<d<<end1;}则程序执行后变量a,b,c,d的值分别是 【12】 。
点击查看答案
相关试题
下列叙述中正确的是( )。
关系R和关系S的并运算是( )。
下面是类MyChss的定义,对定义中语句描述正...
调试程序过程中主要会发现三类错误,不包括...
在结构化程序设计思想提出之前,在程序设计...