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

题目内容 (请给出正确答案)
有如下程序:include using namespace std;class Base{private:char c;public:Base(ch

有如下程序:#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.xy

B.yx

C.x

D.y


参考答案

更多 “ 有如下程序:include using namespace std;class Base{private:char c;public:Base(ch 有如下程序:#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 ” 相关考题
考题 有以下程序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

考题 有以下程序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 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 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

考题 有以下程序:includeusing namespace std;class BASE{private: char c;public: BASE(c 有以下程序: #include <iostream> using namespace std; class BASE { private: char c; public: BASE(char n):c(n);{} virtual~BASE() { cout<<c; } }; class DERIVED:public BASE { char c; pA.XYB.YXC.XD.Y

考题 有以下程序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

考题 有如下程序: #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

考题 有以下程序includeusing namespace std;class Base{private:char c;public:Base(char 有以下程序 #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