网友您好, 请在下方输入框内输入要搜索的题目:
题目内容
(请给出正确答案)
请阅读下述代码,写出程序执行的结果
#include <iostream>
using namespace std;
class CBase
{
public:
virtual void print()
{
cout<< "base" << endl;
}
void DoPrint()
{
print();
}
};
class CChild1: public CBase
{
public:
virtual void print()
{
cout<< "child1" << endl;
}
};
class CChild2: pu
{
public:
virtual void pri
{
cout<< "chil
}
};
void DoPrint(CB
{
base->DoPrint
}
void main()
{
CBase* base =
CChild1* child
CChild2* child
DoPrint(child1
DoPrint(child2
DoPrint(base);
delete base;
base = child1;
base->print();
delete child1;
delete child2;
}
参考答案
更多 “ 请阅读下述代码,写出程序执行的结果#include iostreamusing namespace std;class CBase{public:virtual void print(){cout "base" endl;}void DoPrint(){print();}};class CChild1: public CBase{public:virtual void print(){cout "child1" endl;}};class CChild2: pu{public:virtual void pri{cout "chil}};void DoPrint(CB{base-DoPrint}void main(){CBase* base =CChild1* childCChild2* childDoPrint(child1DoPrint(child2DoPrint(base);delete base;base = child1;base-print();delete child1;delete child2;} ” 相关考题
考题
有以下程序includeint i=0;void fun(){{ Static int i=1 Std::cont
有以下程序 #include<iostream,h> int i=0; void fun() { { Static int i=1 Std::cont<<i++<<','; } Std::cout<<i<<','; } int main() { fun();fun(); return 0; } 程序执行后的输出结果是( )。A.1,2,1,2,B.1,2,2,3,C.2,0,3,0,D.1,0,2,0,
考题
有以下程序: include int i=0;void fun(){{static iht i=1; std::cout
有以下程序: # include <iostream> int i=0; void fun() {{static iht i=1; std::cout<<i++<<','; } std:: cout<<i<<','; } int main() { fun(); fun(); return 0; }程序执行后的输出结果是______。A.1,2,1,2,B.1,2,2,3,C.2,0,3,0,D.1,0,2,0,
考题
请阅读下列程序代码,然后将程序的执行结果补充完整。横线处应填写的内容是( )。 程序代码:执行结果: In Situation 0 no Exception caught in Proc finallyA.In Situation 1B.In SituationC.with CatchD.int iArray 1
考题
阅读以下程序,写出程序运行后的输出结果是 ______。includevoid main(){ char a[]={
阅读以下程序,写出程序运行后的输出结果是 ______。 #include<iostream.h> void main(){ char a[]={'H','e','r','1',‘o’,'\0'}; int i, j; i=sizeof(a)/sizeof(char); j=strlen(a) cout<<i<<' '<<j; }A.6 6B.5 6C.1 5D.6 5
考题
阅读以下程序,写出程序运行后的输出结果是 ______。includevoid main(){char a[]={'
阅读以下程序,写出程序运行后的输出结果是 ______。 #include<iostream.h> void main(){ char a[]={'H','e','1','1','o','\0'}; int i,j; i=sizeof(a)/sizeof(char); j=strlen(a) cout<<i<<‘ ’<<j;A.6 6B.5 6C.1 5D.6 5
考题
阅读下列说明和C++代码,填写程序中的空(1)~(6),将解答写入答题纸的对应栏内。
【说明】
以下C++代码实现一个简单绘图工具,绘制不同形状以及不同颜色的图形。部分类及其关系如图6-1所示。
【C++代码】
#include?#include?using?namespace?std;class?DrawCircle?{??????//绘制圆形,抽象类? ? ? public: (1);//定义参数为?int?radius,?int?x,?inty? ?virtual~DrawCircle()?{?}};class?RedCircle:public?DrawCircle?{????//绘制红色圆形? ? ? ? public: void?drawCircle(intradius,?int?x,?int?y)?{cout??drawCircle?=?drawCircle;? }? ?virtual~shape()?{?}? public:? ?virtual?void?draw()?=?0;};class?Circle:public?Shape?{????//圆形? ? private:? ? ?int?x,y,radius;? ? public:? Circle(int?x,inty,int?radius,DrawCircle?*drawCircle)? (3)? {? this->x?=?x;? ?this->y?=?y;? ? this->radius?=?radius; }? ? ? public:? void?draw(){? drawCircle?-> (4); }};int?main(){Shape?*redCirclenew?Circle(100,100,10,????(5)????);//绘制红色圆形? Shape?*greenCircle=new?Circle(100,100,10, (6)??);//绘制绿色圆形redCircle >draw();? ?greenCircle?->draw();? ?return?0;}
考题
请仔细阅读程序,将程序的执行结果详细的写出来。注意字符和标点符号的书写 #include <stdio.h> int main() { int i,j=4; for(i=j;i<=2*j;i++) switch(i/j) { case 0: case 1: printf("*");break; case 2: printf("#"); } return 0; }
考题
阅读下面的程序,写出程序的运行结果_______ #include<stdio.h> int main() { int i,j; i=010; j=9; printf("%d,%d",i-j,i+j); }
考题
请仔细阅读程序,将程序的执行结果详细的写出来。注意字符和标点符号的书写 # include "stdio.h" int main() { int n1,n2=1234; while(n2!=0) {n1=n2%10; n2=n2/10; printf("%d",n1); } return 0; }
热门标签
最新试卷