下列程序片段中,能通过编译的是( )。
A.public abstract class Animal{public void speak( );}
B.public abstract class Animal{public void speak( ){};}
C.public class Animal{pubilc abstract void speak( );}
D.public abstract class Animal{pubile abstract void speak( ){};}
第1题:
第2题:
下列程序片段中,能通过编译的是( )。
A.public abstract class Animal{ public void speak;}
B.public abstract class Animal{ public void speak{);}
C.public class Animal{ pubilc abstract void speak;}
D.public abstract class Animal{ pubile abstract void speak{};}
第3题:
下列程序片段中,能通过编译的是( )。
A.public abstract class Animal{ public void speak( );}
B.public abstract class Animal{ public void speak( ){};}
C.public class Animal{ pubilc abstract void speak( );}
D.public abstract class Animal{ pubilc abstract void speak( ){};}
第4题:
下列程序片段中,能通过编译的是( )。
A.public abstract class Animal{ public void speak;}
B.public abstract class Animal{ public void speak{);}
C.public class Animal{ pubilc abstract void speak;}
D.public abstract class Animal{ pubile abstract void speak{};}
第5题:
有如下程序:
nclude<iostream>
using namespace std;
class Animal{
public:
virtual char*getType()const{return“Animal”;}
virtual char*getVoice()const{return“Voice”;}
};
class Dog:public Animal{
public:
char*getType()const{rgturn“Dog”;}
char*getVoice()const{retum“Woof”;}
};
void type(Animal&A){cout<<a.getType();}
void speak(AnimalA){cout<<a.getVoice();}
int main(){
Dog d.type(D);tout<<“speak”;speak(D);cout<<endl;
return 0;
}
运行时的输出结果是【 】
第6题:
下列程序的运行结果是【 】。
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::data
void main(void)
{
SomeClass my_class(1001),your_class(2002);
your_class. set_data(4004);
my_elass. show_data()
}
第7题:
( 12 )有如下程序:
#include <iostream>
using namespace std
class Animal{
public:
virtual char* getType () const { return "Animal" ; }
virtual char* getVoice () const { return "Voice" ; }
};
Class Dog : public Animal {
public:
char* getType ( ) const {return "Dog" ; }
char* getVoice ( ) const {return "Woof"}
};
void type ( Animal& a ) {cout<<a.getType ( ) ; }
void speak ( Animal a ) {cout<<a.getVoice ( ) ; }
int main ( ) {
Dog d; type ( d ) ; cout<<" speak" ; speak ( d ) ; cout<<endi;
return 0;
}
运行时的输出结果是【 12 】 。
第8题:
下列程序片段中,能通过编译的是
A.public abstract class Animal{ public void speak();}
B.public abstract class Animal{ public void speak(){}}
C.public class Animal{ public abstract void speak();}
D.public abstract class Animal{ public abstract void speak(){}}
第9题:
有如下程序:
include<iostream>
using namespaee std;c lass Animal{
public:
virtual char*getType( )const{return"Animal";}
virtual char*getVoice( )const{return"Voice";}
};
class Dog:public Animal{
public:
char*getType( )const{return"Dog";}
char*getVoice( )eonst{return"Woof";}
};
void type(Animal&A) {cout<<a.getType( );}
void speak(Animal A) {eout<<a.getVoice( );}
int main( ){
Dog d;type(D) ;cout<<"speak";speak(D) ;cout< return 0;
}
程序的输出结果是______。