有如下程序: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.书:精彩人生
有如下程序: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.书:精彩人生
相关考题:
( 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 )书:精彩人生
如下程序的输出结果是______。 include using namespace std; class Pet{ char nam 如下程序的输出结果是______。include<iostream>using namespace std;class Pet{char name[10];public:Pet(char*nanle){strcpy(this->name,name);}const char*getName( )const{return name;}virtual void call( )eonst=0;};class Dog:public Pet{public:Dog(char*name):Pet(name){ }void call( )eonst{cout<<"汪汪叫";}};class Cat:public Pet{public:Cat(char*name):Pet(name){ }void call( )const{eout<<"喵喵叫";}};int main( ){Pet*petl=new Dog("哈克"),*pet2=new Cat("吉米");eout<<petl->getName( );petl->call( );eout<<endl;cout<<pet2->getName( );pet2->call( );eout<<endl;return 0;}
有以下程序:includeincludeusingnameSpacestd;classperson{ intage; Char*nam 有以下程序:include <iostream>include <string>using nameSpace std;class person{int age;Char * name;public:person ( int i, Char * str ){int j;j = strlen( str ) + 1;name = new char[ j ];strcpy( name, str );age = i;}~person(){delete name;cout<<"D";}void display(){cout<<name<<":"<<age;}};int main(){person demo( 30,"Smith" );demo.display();return 0;}则该程序的输出结果为:【 】。
有如下程序:#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.书:精彩人生
有如下程序: include using namespace std; class Pet{ char name[10]; public: Pet(c 有如下程序:include<iostream>using namespace std;class Pet{char name[10];public:Pet(char*name){strcpy(this->name,name);}const char*getName()const {return name;}virtual void call()const=0;};class Dog:public Pet{public:Dog(char*name):Pet(name){}void call()const{cout<<"汪汪叫":}};class Cat:public Pet{public:Cat(char*name):Pet(name){}void call()const{cout<<"喵喵叫";}};int main(){Pet*pet1=new Dog("哈克"),*pet2=new Cat("吉米");cout<<pet1->getName();pet1->call();cout<<end1;cout<<pet2->getName();pet2->call();cout<<end1;return 0;}程序的输出结果是______。
有以下程序: #include 〈iostream〉 #include 〈string〉 using namespace std; class visited { private: int number; char *name; public: static int glob; void set mes(char *a); }; void visited::set mes(char *a) { name=new char[strlen(A) +1]; strcpy(name,A) ; number=++glob; } int visited::glob-O; int main() { visited person[10]; int i; char str[8]; for(i=0;i5;i++) { cinstr; person[i] .set mes(str); } coutA.5B.4C.3D.2
有如下程序:includeusing namespace std;class Name{char name[20];public:Name( ){s 有如下程序: #include<iostream> using namespace std; class Name{ char name[20]; public: Name( ){strepy(name," ");tout<<'?';} Name(char*fname){strcpy(name,fname);cout<<'?';} }; int main( ){ Name name[3]={Name("张三"),Name("李四")}; return 0; } 运行此程序输出符号“?”的个数是A.0B.1C.2D.3
有如下程序:includeusing namespace std;class Toy{public:Toy(char*_n){strcpy(name 有如下程序: #include<iostream> 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 main( ){ Toy tl("Snoopy"),t2("Mickey"),t3("Barbie"); cout<<t1.getCount( )<<endl; return 0; } 程序的输出结果是A.1B.2C.3D.运行时出错
有如下程序: #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.书:精彩人生