下列程序运行时输出的结果是( )。 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.出错信息
第1题:
有如下程序: #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
第2题:
有如下程序: #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
第3题:
下列程序的输出结果是______。
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;
}
第4题:
有如下程序:
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;
}
程序的输出结果是
第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
第6题:
下列程序的输出结果是______。
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;
}