( 28 )有如下程序#include iostreamusing namespace std;class A {public:A(int i):rl(i) {}void print() {cout'e'r1'-';}void print() const {cout'C'rl*rl'-';}private:int rl;};int main(){A al(2); const A a2(4);Al.print();a2.print();Return 0;}运行时的输出结果是A )运行时出错B ) E2-C16-C ) C4-C16-D ) E2-E4-

( 28 )有如下程序

#include <iostream>

using namespace std;

class A {

public:

A(int i):rl(i) {}

void print() {cout<<'e'<<r1<<'-';}

void print() const {cout<<'C'<<rl*rl<<'-';}

private:

int rl;

};

int main(){

A al(2); const A a2(4);

Al.print();a2.print();

Return 0;

}

运行时的输出结果是

A )运行时出错

B ) E2-C16-

C ) C4-C16-

D ) E2-E4-


相关考题:

若类A和类B的定义如下:includeclass A{int i,j;public:int geti(){return i;}};class 若类A和类B的定义如下: #include<malloc.h> class A { int i,j; public: int geti() { return i; } }; class B:public A { int k; public: void make() { k=i*j; } }; 则上述定义中非法的表达式是( )。A.k=i*jB.int k;C.return i;D.void make();

有以下程序: include using namespace std; int f(int); int main() {int i;for(i=0; 有以下程序:include <iostream>using namespace std;int f(int);int main(){int i;for(i=0;i<5;i++)cout<<f(i)<<" ";return 0;}int f(int i){static int k=1;for(;i>0;i--)k+=i;

设有如下程序includemain(){int**k,*j,i=100;j=i;k=j;printf("%d\n",**k);} 设有如下程序 #include<stdio.h> main() { int**k,*j,i=100; j=i;k=j; printf("%d\n",**k); } 上述程序的输出结果是______。A.运行错误B.100C.i的地址D.j的地址

设有如下程序includemain(){int **k, *j,i=100;j=i; k=j;printf("%d\n"”,** 设有如下程序 #include<stdio.h> main() { int **k, *j,i=100; j=i; k=j; printf("%d\n"”,**k); } 上述程序的输出结果是______。A.运行错误B.100C.i的地址D.j的地址

下面程序的运行结果为includeclass A{ int num;public: A(int){num=i;} A(ABm){num 下面程序的运行结果为 #include<iostream.h> class A { int num; public: A(int){num=i;} A(ABm){num=a.num++;} void print(){cout<<num;} }; void main() { Aa(1),b(a); a.print(); b.print(); }A.11B.12C.21D.22

分析以下程序的执行结果【】。include class S{ int A[10]; public: int operato 分析以下程序的执行结果【 】。include <iostream. h>class S{int A[10];public:int operator () (int);};int S: :operator() (int x) {return A[x];}void main() {S a;int i,j;for (i=0; i<10; i++)a(i)=i*2;for (i=0; i<10; i++)cout<<a(i)<<" ";cout<<end1; }

有如下程序:includeusing namespaee std;class A{public:A(int i):rl(i){ }void prin 有如下程序: #include<iostream> using namespaee std; class A{ public: A(int i):rl(i){ } void print( ){cout<<'E'<<rl<<'-';} void print( )const}cout<<'C'<<rl*rl<<'-';} private: int rl; }; int main( ){ A al(2);eonst A a2(4); a1.print( );a2.print( ); return 0; } 程序的输出结果是A.运行时出错B.E2-C16-C.C4-C16-D.E2-E4-

有如下程序:includeusing namespace std;Class TestClass{int a;public:TestClass(in 有如下程序: #include<iostream> using namespace std; Class TestClass {int a; public: TestClass(int x){a=x;} void show(){cout<<a;}}; class TestClass1:public TestClass {int b; public: TestClass1(int i):TestClass(i+1),b(i){} voiA.5B.1C.0D.2

设有如下程序includemain(){int**k, *j, i=100;j=i, k=j;printf("%d\n",**k 设有如下程序#include<atdio.h>main(){int**k, *j, i=100;j=i, k=j;printf("%d\n",**k);}上述程序的输出结果是______。A.运行错误B.100C.i的地址D.i的地址

阅读下列说明和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;}