下列程序运行时输出的结果是( )。 Option Base 1 Private Sub Form_Click() Const a=6 Dim x (a) As Integer For I=1 to a x(i)=1^2 Next I Print x(i) End SubA.36B.25C.1D.出错信息

题目

下列程序运行时输出的结果是( )。 Option Base 1 Private Sub Form_Click() Const a=6 Dim x (a) As Integer For I=1 to a x(i)=1^2 Next I Print x(i) End Sub

A.36

B.25

C.1

D.出错信息


相似考题
更多“下列程序运行时输出的结果是()。Option Base 1Private Sub Form_Click() Const a=6 Dim x (a) As ”相关问题
  • 第1题:

    有如下程序:includeusing namespace std;class Base{int x;public:Base(int n=0):x(n

    有如下程序: #include<iostream> using namespace std; class Base{ int x; public: Base(int n=0):x(n){cout<<n;} int getX( )const{return x;} }; class Derived:public Base{ int y; public: Derived(int m,int n):y(m),Base(n){tout<<m;} Derived(int m):y(m){cout<<m;} }; int main( ){ Derived dl(3),d2(5,7); return 0; } 程序的输出结果是

    A.375

    B.357

    C.0375

    D.0357


    正确答案:C
    解析:有如下程序:  #includeiostream>  using namespace std;  class Base{  int x;  public:  Base(int n=0):x(n){coutn;}  int getX( )const{return x;}  };  class Derived:public Base{  int y;  public:  Derived(int m,int n):y(m),Base(n){toutm;}  Derived(int m):y(m){coutm;}  };  int main( ){  Derived dl(3),d2(5,7);  return 0;  }  程序的输出结果是  

  • 第2题:

    有如下程序: include using namespace std; class Base{ int x; pu

    有如下程序: #include<iostream> using namespace std; class Base{ int x; public: Base(int n=0):x(n){cout<<n;) int getX()const{return x;} }; class Derived:public Base{ int y; public: Derived(int m,int n):y(m,)Base(n){cout<<m;} Derived(int m):y(m){cout<<m;} }; int main(){ Derived d1(3),d2(5,7) return 0; }运行时的输出结果是

    A.375

    B.357

    C.375

    D.357


    正确答案:C

  • 第3题:

    下列程序的输出结果是______。 include using namespace std; class base { public: in

    下列程序的输出结果是______。

    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 deriveB:public base

    {

    public:

    deriveB(int x):base(x){}

    void set(int m){n+=m;cout<<n<<'';}

    };

    int main( )

    {

    deriveA d1(1);

    deriveB.d2(3);

    base*pbase;

    pbase=&d1;

    pbase->set(1);

    pbase=&d2;

    pbase->set(2);

    return 0;

    }


    正确答案:25
    25 解析:本题考核虚函数的定义和调用。在C++中,一个基类指针(或引用)可以用来指向它的派生类对象,而且通过这样的指针(或引用)调用虚函数时,被调用的是该指针(或引用)实际所指向的对象类的那个重定义版本。题中基类成员函数set( )被定义成虚函数,而且其派生类 deriveA和deriveB都有函数set( )的重定义版本,所以通过指针pbase的两次调用分别调用的是派生类deriveA和deriveB中定义的版本,即输出25。

  • 第4题:

    有如下程序: include using namespace std; class Wages{//“工资”类 double base; //

    有如下程序:

    include<iostream>

    using namespace std;

    class Wages{ //“工资”类

    double base; //基本工资

    double bonus; //奖金

    double tax; //税金

    public:

    Wages(double CBase,double CBonus,double CTax):

    base(CBase),bonus(CBonus),tax(CTax){}

    double getPay()const; //返回应付工资额

    Wages operator+(Wages w)const; //重载加法

    };

    double Wages::getPay()const{return base+bonus-tax;}

    Wages Wages::operator+(Wages W)const{

    return Wages(base+w.base,bonus+w.bonus,tax+w.tax);

    }

    int main(){

    Wages w1(2000,500,100),w2(5000,1000,300);

    cout<<(w1+w2).getPay0<<end1;

    return 0;

    }

    程序的输出结果是


    正确答案:8100
    8100 解析:此题考查运算符重载。首先从主函数入手,定义了类 Wages的对象w1和w2,然后调用重载运算符+,计算对象w1和w2中CBase、CBonus以及CTax的和,分别是7000、1500、400,然后调用getPay()成员函数,计算base+bonus-tax,7000+1500-400=8100。

  • 第5题:

    有如下程序:

    #include<iostream>

    Usingnamespacestd;

    classBase{

    public:

    Base(intx=O):valB(x){cout<<valB;)

    ~Base( ){cout<<valB;)

    Private:

    intvalB:

    };

    classDerived:publicBase{

    public:

    Derived(intX=0,inty=0):Base(x),valD(y)(cout<<valD;)

    ~Derived( ){cout<<valD;)

    private:

    intvalD;

    };

    intmain( ){

    Derivedobj12(2,3);

    return0;

    }

    运行时的输出结果是( )。

    A.2332

    B.2323

    C.3232

    D.3223


    正确答案:A
    A。【解析】本题使用析构函数。

  • 第6题:

    下列程序的输出结果是______。 include class base { int x,y; public: base(int i,i

    下列程序的输出结果是______。

    include<iostream.h>

    class base

    {

    int x,y;

    public:

    base(int i,int j){x=i;y=j;}

    virtual int add( ){return x+y;}

    };

    class three:public base

    {

    int z;

    public:

    three(int i,int j,int k):base(i,j){z=k;)

    int add( ){return(base::add( )+z);}

    };

    void main( )

    {

    three*q=new three(10,20,30);

    cout<<q->add( )<<endl;

    }


    正确答案:60
    60 解析:本题考察继承中子类对父类的继承方式,注意子类的add成员函数,它直接使用了父类的成员函数进行运算。