网友您好, 请在下方输入框内输入要搜索的题目:

题目内容 (请给出正确答案)

有如下程序: #include<iostream> usingnamespacestd; classPublication{//出版物类 charname[30]; public: Publication(char*name=”未知名称”){ ~strcpy(this一>name,name); } constchar*getName( )const{returnname;} virtualconstchar*getType( )const{return”未知类型”;} }; classBook:publicPublication{//书类

public: Book(char*name):Publication(name){} virtualconstchar*getType( )const{return"书";} }; voidshowPublication(Publication&p){ cout<<p.getType( )<<":"<<p.getName( )<< endl; } intmain( ){ Bookbook(”精彩人生”); showPublication(book); return0; } 运行时的输出结果是( )。

A.未知类型:未知名称

B.未知类型:精彩人生

C.书:未知名称

D.书:精彩人生


参考答案

更多 “ 有如下程序: #includeiostream usingnamespacestd; classPublication{//出版物类 charname[30]; public: Publication(char*name=”未知名称”){ ~strcpy(this一name,name); } constchar*getName( )const{returnname;} virtualconstchar*getType( )const{return”未知类型”;} }; classBook:publicPublication{//书类public: Book(char*name):Publication(name){} virtualconstchar*getType( )const{return"书";} }; voidshowPublication(Publicationp){ coutp.getType( )":"p.getName( ) endl; } intmain( ){ Bookbook(”精彩人生”); showPublication(book); return0; } 运行时的输出结果是( )。A.未知类型:未知名称B.未知类型:精彩人生C.书:未知名称D.书:精彩人生 ” 相关考题
考题 有如下程序: include using namespace std; class Monitor{ public: Monitor(cha 有如下程序:include<iostream>using namespace std;class Monitor{public:Monitor(char t):type(t){ }void Print( )const{cout<<"The type of monitor is"<<type private:char type;};class Computer{public:Computer(int i,char C) :______{}void Print( )const{eout<<"The computer is"<<id<<endl;mort.Print( );}private:int id;Monitor mon;};int main( ){const Computer myComputer(101,'B');myComputer.Print( );return 0;}请将程序补充完整,使程序在运行时输出:The computer is 101The type of monitor is B

考题 ( 32 )有如下程序#includeiostreamusing 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){coutp.getType()":"p.getName()endl;}int main(){Book book(" 精彩人生 ");showPublication(book);return 0;}运行时的输出结果是A )未知类型:未知名称B )未知类型:精彩人生C )书:未知名称D )书:精彩人生

考题 有如下程序:includeusing namespace std;class Base{private:char c;piblic:Base(cha 有如下程序: #include<iostream> using namespace std; class Base { private: char c; piblic: Base(char n):c(n){} ~Base() { cout<<C; } }; class DeriVed:public Base { private: char c; public: Derived(char n):Base(n+1),c(n){} ~Derived() { cout<<c; } }; int main() { Derived obj('x'); return 0; } 执行上面的程序将输出A.xyB.yxC.xD.y

考题 有如下程序:#includeiostreamusing 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(Publicationp){coutP.getType()“:”P.getName()endl;}int main(){Book book(”精彩人生”);showPublication(book);return 0;}运行时的输出结果是A.未知类型:未知名称B.未知类型:精彩人生C.书:未知名称D.书:精彩人生

考题 有如下程序:includeusing namespace std;class Publication{//出版物类char name[30] 有如下程序: #include<iostream> 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<<p.getType( )<<":"<<P.getName( )<<endl;} int main( ){ Book book("精彩人生"); showPublication(book); return 0; } 程序的输出结果是A.未知类型:未知名称B.未知类型:精彩人生C.书:未知名称D.书:精彩人生

考题 有以下程序:include include using namespace std;class base{private: cha 有以下程序: #include <iostream> #include <string> using namespace std; class base { private: char baseName[10]; public: base ( ) { strcpy (baseName, "Base"); } virtual char *myName() {A.DerivedBaseB.BaseBaseC.DerivedDerivedD.BaseDerived

考题 以下程序的输出结果是()。includeincludeusing namespace std;void func(cha 以下程序的输出结果是( )。 #include<iostream> #include<stdlib> using namespace std; void func(char **m) { ++m; cout<<*m<<endl; } main() { static char *a[]={"MORNING","AFTERNOON","EVENING"); char **n; n=a; func(n); system("PAUSE"); return 0; }A.为空B.MORNINGC.AFTERNOOND.EVENING

考题 有以下程序include using namespace std:class Base{private:char c;public:Base(cha 有以下程序#include <iostream>using namespace std:class Base{private: char c;public: Base(char n) :c(n) {} ~Base ( ) { cout<<c; }}; class Derived : public Base{private: char c;public: Derived(char n):Base (n+1),c(n) {} ~Derived() { cout<<c; }};int main(){ Derived obj('x'); return 0;} 执行后的输出结果是A.xyB.yxC.xD.y

考题 有如下程序:include using namespace std;class Base{private:charc;public:Base(cha 有如下程序:#include <iostream>using namespace std;class Base{private: char c;public: Base(char n) :c(n){} ~Base() { cout<<c; } };class Derived: public Base{private: char c; public: Derived(char n):Base(n+1),c(n) {} ~Derived() { cout<<c; }};int main (){ Derived obj ('x'); return 0;}执行上面的程序净输出A.xyB.yxC.xD.y