有如下程序: #includeiostream usingnamespacestd; className{ charname[20]; public: Name( ){ strcpy(name,"");cout?; } Name(char*fname){ strcpy(name,fname);cout?; } }; intmain( ){ Namenames[3]={Name(”张三”),Name(”李四”)); return0; } 运行此程序输出符号?的个数是( )。A.OB.1C.2D.3
有如下程序: #include<iostream> usingnamespacestd; className{ charname[20]; public: Name( ){ strcpy(name,"");cout<<?; } Name(char*fname){ strcpy(name,fname);cout<<?; } }; intmain( ){ Namenames[3]={Name(”张三”),Name(”李四”)); return0; } 运行此程序输出符号?的个数是( )。
A.O
B.1
C.2
D.3
相关考题:
( 29 )有如下程序:#includeiostreamusing 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;}运行此程序输出符号?的个数是A ) 0B ) 1C ) 2D ) 3
有以下程序includeincludeusing namespace std;class base{private:charbas 有以下程序 #include<iostream> #include<string> using namespace std; class base { private: charbaseName[10]; public: base() { strcpy(baseName,"Base"); } virtual char*myName() return baseName; } char *className() { return baseName; } }; class Derived: public base { private: char derivedName[10]; public: Derived() { strcpy(derivedName,"Derived"); } char *myName() { return derivedName; } char *className() { return derivedName; } }; void showPtr(base p) { cout<<p.myName0<<" "<<p.className(); } int main() { base bb; Derived dd; showPtr(dD) ; retum 0; } 动行后的输出结果为A.Derived BaseB.Base BaseC.Derived DerivedD.Base Derived
有如下程序:#includeiostreamusing flamespace 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;}运行此程序输出符号?的个数是A.0B.1C.2D.3
有以下程序include include using namespace std;class base{private:char 有以下程序 #include <iostream> #include <string> using namespace std; class base { private: char baseName[10]; public: base () { strcpy(baseName,"Base"); } virtual char *myName() { return baseName; } char *className() { return baseName; } }; class Derived : public base { private: char derivedName[10]; public: Derived() { strcpy(derivedName,"Derived"); } char *myName() { return derivedName; } char *className() { return derivedName; } }; void showPtr(base p) { cout<<p.myName () <<" "<<p.className (); } int main () { base bb; Derived dd; showPtr(dd); return 0; } 运行后的输出结果为A.Derived BaseB.Base BaseC.Derived DerivedD.Base Derived
有如下程序: 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 include using namespace std;class base {private:char 有以下程序 #include <iostream> #include <string> using namespace std; class base { private: char baseName[10]; public: base() { strcpy(baseName,"Base"); } virtual char *myName() { return baseName; } char *className() { Return baseName; } }; class Derived: public base { private: char derivedName[10]; public: Derived() { strcpy(derivedName,"Derived" ); } char *myName() { return derivedName; } char *className() { return derivedName; } }; void showPtr(base p) { cout<<p.myName()<<" "<<p.className(); } int main() { base bb; Derived dd; showPtr(dd); return 0; } 运行后的输出结果为A.Derived BaseB.Base BaseC.Derived DerivedD.Base Derived
有如下程序: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
有如下程序:include using namespace std;class AA{public: virtual void f() {cout 有如下程序: #include <iostream> using namespace std; class AA { public: virtual void f() { cout<< "AA"; } }; class BB : public AA { public: BB() { cout << "BB"; } }; claA.AAB.AABBCCC.BBAABBCCD.BBBBAACC
有如下程序: #includeiostream usingnamespacestd; className{ charname[20]; public: Name( ){ strcpy(name,"");cout'?'; } Name(char*fname){ strcpy(name,fname);cout'?'; } }; intmain( ){ Namenames[3]={Name(”张三”),Name(”李四”)); return0; } 运行此程序输出符号?的个数是( )。A.OB.1C.2D.3