题目详情
当前位置:首页 > 职业培训考试
题目详情:
发布时间:2024-08-01 00:46:54

[填空题]分析以下程序的执行结果 [12] 。 #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; }

更多"分析以下程序的执行结果 [12] 。 #include <ios"的相关试题:

[填空题]分析以下程序执行结果 [14] 。 #include<iostream.h> int f (int x, int y){ return x,y; } double f (double x, double y) { return x,y; } void main( ) { int a=4, b=6; double c=2.6, d=7.4; cout<<f (a, b) <<","<<f (c, d) <<end1; }
[填空题]分析以下程序执行结果 [14]
#include<iostream.h>
int f (int x, int y)
return x,y;

double f (double x, double y)
return x,y;

void main( )
int a=4, b=6;
double c=2.6, d=7.4;
cout<<f (a, b) <<","<<f (c, d) <<end1;

[填空题]分析以下程序的执行结果 [12]
#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;
[填空题]分析以下程序的执行结果 【14】
#include<iostream.h>
class Sampleint x, y;
public:
Sample( ) x=y=0;
Sample(int a, int b) x=a; y=b;
~Sample( )if(x==y)
cout<<"x=y"<<end1;
else
cout<<"x!=y" <<end1;void disp( )cout<<"x="<<x<<",y="<<y<<end1;;
void main( )Sample s 1 (2,3);
s1. disp( );

[填空题]分析以下程序的执行结果 【14】 。 #include<iostream.h> class Sample { int x, y; public: Sample( ) {x=y=0; } Sample(int a, int b) { x=a; y=b;} ~Sample( ) { if(x==y) cout<<"x=y"<<end1; else cout<<"x!=y" <<end1; } void disp( ) { cout<<"x="<<x<<",y="<<y<<end1; } }; void main( ) { Sample s 1 (2,3); s1. disp( ); }
[单项选择]以下程序的执行结果是( )。
#include<iostream.h>
template<class T>
class Sample

T n;
Public:
Sample (T i)n=i;)
void operator ++( );
void disp( ) cout<<"n="<<n<<endl;

template<class T>
void Sample<T>:: opetator ++( )

n+=1;∥不能用n++,因为double型不能用++

void main( )

Sample<char>s(’a’);
S++;
s.disp( );

A. n=a
B. a=O
C. n=b
D. a=b
[填空题]请分析下面的程序并给出该程序的执行结果______。
#include <iostream>
class AA
int a;
public:
AA( ) cout<<" Initializing AA!/n" ;
AAM( ) cout<<" Destroying AA!/n" ;
;
class BB
int b;
AA p;
public:
BB( ) cout<<"Initializing BB!/n" ;
~BB( ) cout<<"Destroying BB!/n" ;
;
void main( )
BB X;
cout<<"Ending main!/n’ ;

[单项选择]以下程序执行结果是 ( )。
#include <iostream.h>
class Base

public
virtual void fun( ) cout<<"B";
;
class Derived

public:
Derived( ) cout<<"D";
virtual void fun( ) Base::fun( ); cout<<"C";

int main ( )

Base *ptr;
Derived obj;
ptr=&obj;
p->fun ( );
return 0;

A. DBC
B. DCB
C. BDC
D. CBD
[填空题]写出下列程序的执行结果是 【8】
已知:’a’转换成整数对应的是97。
程序如下:
class Testl
public static void main(String[] args)
char a=’d’;
int b=a;
float c=a;
double d=a;
System.out.println("a="+
  • a);
    System.out.println("b="+
  • b);
    System.out.println("c="+
  • c);
    System.out.println("d="+
  • d);


[单项选择]以下程序执行后的输出结果是
#include<iostream>
using namcspace std;
void try(int,int,int,int);
int main( )

int x,y,z,r;
x=1;
y=2;
try(x,y,z,r);
cout<<r<<end1;
return 0;

void try(int x,int y, int z,int r)

z = x+y;
x = x*x;
y = y*y;
r = z+x+y;

A. 18
B. 9
C. 10
D. 不确定
[填空题]以下程序的执行结果是 。 #include<iostream. h> class Sample { public: int x: int y; void disp( ) { cout<<"x="<<x<<",y="<<y<<end1; } }; void main( ) { int Sample:: ** pc; Sample s; pc=& Sample: :x; s.*pc=10; pc:=&Sample: :y; s.*pc=20; s.disp( ); }
[单项选择]以下程序执行后的输出结果是 #include<iostream>. using namespace std; void try(int,int,int,int); int main( ) { int x,y,z,r; x=1; y=2; try(x,y,z,r); cout<<r<<end1; return 0; } void try(int x,int y, int z,int r) { z = x+y; x = x*x; y = y*y; r = z+x+y; }
A. 18
B. 9
C. 10
D. 不确定
[填空题]以下程序的执行结果为【 】。   #include<iostream>   using namespace std;   class base   {    public:     virtual void who( )    {     cout < < "base class" < <end1;    };    class derivel:public base    {     public:      void who( )     {      cout < <"derivel class" < <end1;     };     }    class derive2:public base     {      public:       void who( )      {       cout< <"derive2 class"< <end1;      }     };     void main( )     {      base obj1,* p;      derivel obi2;      derive2 obj3;      p=&obj1;      p->who( );      p=&obj2;      p->who( );      p=&obj3;      p->who( );     }

我来回答:

购买搜题卡查看答案
[会员特权] 开通VIP, 查看 全部题目答案
[会员特权] 享免全部广告特权
推荐91天
¥36.8
¥80元
31天
¥20.8
¥40元
365天
¥88.8
¥188元
请选择支付方式
  • 微信支付
  • 支付宝支付
点击支付即表示同意并接受了《购买须知》
立即支付 系统将自动为您注册账号
请使用微信扫码支付

订单号:

截图扫码使用小程序[完全免费查看答案]
请不要关闭本页面,支付完成后请点击【支付完成】按钮
恭喜您,购买搜题卡成功
重要提示:请拍照或截图保存账号密码!
我要搜题网官网:https://www.woyaosouti.com
我已记住账号密码