网友您好, 请在下方输入框内输入要搜索的题目:
题目内容
(请给出正确答案)
下列程序的执行结果为______。 include class Myclass { public: void GetSum(int a)
下列程序的执行结果为______。
include<iostream.h>
class Myclass
{
public:
void GetSum(int a);
static int Sum;
prtvate:
int A;
};
int Myclass::Sum=10;//必须在类外部对静态数据成员初始化
void Myclass::GetSum(int a)
{
A=a;
Sum+=A:
}
vold PrintSum(Myclass& A)
{
cout<<"Sum="<<A. Sum<<endl;
}
void main( )
{
Myclass M,N;
M.GetSum(3);
N.GetSum(7);
PrintSum(M);
}
参考答案
更多 “ 下列程序的执行结果为______。 include class Myclass { public: void GetSum(int a) 下列程序的执行结果为______。include<iostream.h>class Myclass{public:void GetSum(int a);static int Sum;prtvate:int A;};int Myclass::Sum=10;//必须在类外部对静态数据成员初始化void Myclass::GetSum(int a){A=a;Sum+=A:}vold PrintSum(Myclass A){cout<<"Sum="<<A. Sum<<endl;}void main( ){Myclass M,N;M.GetSum(3);N.GetSum(7);PrintSum(M);} ” 相关考题
考题
下面程序运行时输出结果为______。 include include class Rect { public: Rect(int
下面程序运行时输出结果为______。include<iostream.h>includeclass Rect{public:Rect(int l, int w){length=l; width=w;)void Print(){cout<<"Area:"<<length*width<<end1;}void operator delete(void*p){free(p);}private:int length, width;};void main(){Rect *p;p=new Rect(5, 4);p->Print();delete p;}
考题
下列程序的执行结果是【 】。 include int a; int sum_a(void) { a=a+5; return a; }
下列程序的执行结果是【 】。include <iostream. h>int a;int sum_a(void){a=a+5;return a;}void main(void){a = a+sum_a();cout<<a<<endl;}
考题
下列程序的运行结果是【 】。 include class SomeClass { public: SomeClass(int va
下列程序的运行结果是【 】。include <iostream. h>class SomeClass{public:SomeClass(int value) { some_value=value;};void show_data(void) { cout<<data<<"<<~some_value<<endl; };static void set_data(int value) {data=value; }private:static int data;int some_value};int SomeClass::datavoid main(void){SomeClass my_class(1001),your_class(2002);your_class. set_data(4004);my_elass. show_data()}
考题
下面程序运行时输出结果为【】。 include include class Rect { public: Rec
下面程序运行时输出结果为【 】。include<iostream.h>include<malloc.h>class Rect{public:Rect(int1,int w)(length=1;width=w;)void Print(){cout<<"Area:"<<length *width<<endl;)void *operator new(size-t size){return malloc(size);}void operator delete(void *p){free(p)private:int length,width;};void main(){Rect*p;p=new Rect(5,4);p->Print();delete p;}
考题
下列程序的运行结果是______。include class Base { public: void f(int x){cout
下列程序的运行结果是______。include<iostream.h>class Base{public:void f(int x){cout<<“Base:”<<x<<endl;});class Derived:public Base{public:void f(char*str){cout<<“Derived:”<<str<<endl;}};void main(void){Base*pd=ne
考题
下列程序的执行结果是【 】。 include class Myclass { public: void GetSum(int a)
下列程序的执行结果是【 】。include < iostream. h>class Myclass{public:void GetSum(int a)static int Sum:private:int A;};int Myclass:: Sum =10; //必须在类外部对静态数据成员初始化void Myelass: :GetSum(int a){A=a;Sum+=A;}void PrintSum(Myclass A){cout<<"Sum="<<A.Sum<<end1;}void main( ){Myclass M,N;M. GetSum(3)N. GetSum(7)PrintSum(M);}
考题
以下程序的执行结果为()。includeclass myClass{Dublic:myClass(intdata) ;myClass(
以下程序的执行结果为( )。 #include<iostream.h> class myClass { Dublic: myClass(int data) ; myClass(){value=0; }; myClass(myClass obj); void print(){ cout<<value<<end1; } ~myClass(){} private: int value; }; myClass::myClass(int data) {value=data; } myClass::myClass(myClass Obj) { value=obj.value; } void main() { myClass a(100); myClass b(a) ; b.print(); }A.0B.100C.10D.程序编译时出错
考题
以下程序的执行结果为______。include class A {public:A(){cout
以下程序的执行结果为______。include<iostream.h>class A{public:A(){cout<<“a”;}~A(){cout<<“b”;}};class B:public A{public:B(){cout<<“c”;)~B(){cout<<“d”;}};void main(){B b;}
考题
阅读下列说明和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;}
热门标签
最新试卷