下列程序的运行结果是 #include<iostream.h> class Location{ private: int X.Y; public: void init(int=0,int=0); void valueX(int val){X=val;} int valueX( ){ return X;} void valueY
A.5 0 6 4
B.0 0 6 4
C.5 0 6 2
D.0 0 6 2
第1题:
下列程序的运行结果是______。
include<iostream.h>
class test
{
private:
int hum;
public:
test( );
int TEST( ){return num+100;)
~test( );
};
test::test( ){num=0;)
test::~test( ){cout<<"Destructor is active"<<endl;)
void main( )
{
test x[3];
cout<<x[1].TEST( )<<endl;
}
第2题:
下列程序的运行结果是______。
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
第3题:
下列程序的运行结果是______。
include<iostream.h>
class Base
{
public:
virtual void func(int i){cout<<"class Base:"<<i<<end1;)
};
class Derived: public Base
{
public:
void func(double d){cout<<"class Derived:"<<d<<endl;}
};
void main( )
{
Base a,*p=a;
Derived b;
p=&b;
(*p).func(3.3);
}
第4题:
下列程序的运行结果是 #inClUde<iostream.h> class Location{ private: int X,Y; pubhc: void init(int=0,int=0) ; void valueX(int val) {X=val;} int valueX( ) {retum X;} void valueY(int val) {Y=val;} int valueY( ) {retum Y;}};void Location: :init(int initX,int initY) { X=initX; Y=initY;} Void main( ) { Location A,B; A. init( ) ; A. valueX(5) ; cout < < A. valueX( ) < < endl < < A. valueY( ) < < endl; B. init(6,2) ; B. valueY(4) ; cout < < B. valueX( ) < < endl < < B. valueY( ) < < endl;}
A.5
B.0
C.5
D.0 0 0 0 0 6 6 6 6 4 4 2 2
第5题:
下列程序的运行结果是 #include<iostram.h> classLocation{ private: int X,Y; public: void init(int=0, int=0) ; void valueX(int val){X=val:} int valueX(){return X;} void valueY(int val){Y=val;} int valueY(){returnY;}}; void Location∷init(int initX,int initY) { X=initX; Y=initY;} void main() { LocationA,B; A.init(); A.ValueX(5); cout <<A.ValUeX() <<endl<<A,valueY() <<endl; B.init(6,2); B.valueY(4) ; cout<<B.valueX() <<endl<<B.valueY() <<endl;}
A.5 0 6 4
B.0 0 6 4
C.5 0 6 2
D.0 0 6 2