有如下程序
#include
using namespace std;
class A {
public:
A(int i):rl(i) {}
void print( ) {cout<<’e’<
int rl;
};
int main( ){
A al(2); const A a2(4);
Al.print( );a2.print( );
Return 0;
}
运行时的输出结果是
有如下程序
#include
using namespace std;
class Publication{ //出版物类
char name[30];
public:
Publication(char *name=”未知名称”){
strcpy(this->name,name);
}
const char * getName( )const{ return name; }
virtual const char * getType( )const{ return “未知类型”;}
};
class Book: public Publication{ //书类
public:
Book(char *name): Publication(name){}
virtual const char * getType( )const{ return “书“;}
};
void showPublication( Publication &p){
cout<
int main( ){
Book book(“精彩人生”);
showPublication(book);
return 0;
}
运行时的输出结果是
有如下程序
#include
using namespace std;
Class Base{
public:
Base(int x=0):valB(x) {cout<
~Base( ) {cout<
private:
int valB;
};
class Derived:public Base{
public:
Derived(int x=0,int y=0):Base(x),valD(y){cout<
~Derived( ) {cout<
private:
int valD;
};
int main( ){
Derived obj12(2,3);
retuen 0;
}
运行时的输出结果是()
有如下程序:
#include
using namespace std;
class Toy{
public:
Toy(char* _n) { strcpy (name,_n); count++;}
~Toy( ){ count--; }
char* GetName( ){ return name; }
static int getCount( ){ return count; }
private:
char name[10];
static int count;
};
int Toy::count=0;
int mail( ){
Toy t1(“Snoopy”),t2(“Mickey”),t3(“Barbie”);
cout<
}
运行时的输出结果是
有如下程序
#include
using namespace std;
class A{
public:
A(int i=0):r1(i) { }
void print( ) {cout<<’E’<
void print( ) const {cout<<’C’<
void print(int x) {cout <<’P’<
private:
int r1;
};
int main( ) {
A a1;
const A a2(4);
a1.print(2);
a1.print( );
return 0;
}
运行时的输出结果是()
有如下程序:
#include
using namespace std;
class Machine{
static int num;
public:
Machine( ){num++;}
static void showNum( )
{cout<
};
int Machine::num=0;
int main( ){
Machine a[10],b;
Machine::showNum( );
return 0;
}
运行这个程序的输出结果是__________。
有如下程序:
#include
using namespace std;
class Book{
public:
Book(char* t=""){strcpy(titie,t); }
_____________________________
private:
Char title[40];
};
class Novel:public Book{
public:
Novel(char*t=""):B00K (t){}
char*Category()const { return” "文学" }
};
int main(){
Book*pb;
pb=new Novel();
Cout<
return 0;
}
若程序运行时输出结果是“文学”,则划线处缺失的语句是()
有如下程序:
#include
using namespace std;
class Instrument{
public:
virtual void Display()=0;
};
class Piano:public Instrument{
public:
void Display(){/*函数体程序略*/}
};
int, main(){
Instrument s;
Instrument*p=0;
//...;
return 0;
}
下列叙述中正确的是()
有如下程序:
#include
using namespace std;
class Music{
public:
void setTitle(char*str){strcpy(title,str);}
protected:
char type[10];
private:
char title[20];
};
class Jazz:public Music{
public:
void set(char* str){
strcpy(type,"Jazz"); //①
strcpy(title,str); //②
}
};
下列叙述中正确的是()
有如下程序:
#include
using namespace std;
class Name{
char name[20];
public:
Name( ){
strcpy(name,””); cout<<’’;
}
Name(char *fname)){
strcpy(name,fname); cout<’’;
}
};
int main( ){
Name names[3]={Name(“张三”),Name(“李四”)};
Return 0;
}
运行此程序输出符号?的个数是
有如下程序:
#include
using namespace std;
Class B{
public:
B(int xx):x(xx) {++cout; x+=10;}
virtual void show( ) const
{cout<
protected:
static int count;
private:
int x;
};
class D:public B{
public:
D(int xx,int yy):B(xx),y(yy) {++count; y+=100;}
virtual void show( ) const
{cout<
private:
int y;
};
int B::count=0;
int main( ){
B *ptr=new D(10,20);
ptr->show( );
delete ptr;
return 0;
}
运行时的输出结果是()
我来回答: