有以下程序
include <iostream>
using namespace std;
class Base
{
int a;
public:
Base(int x){ a=x; }
void show(){ cout<<a; }
class Derived : public Base
{
int b;
public:
Derived(int i) :Base(i+1),b(i){}
void show() { cout<<b;
};
int main ()
{
Base b(5),*pb;
Derived d(1);
pb=&d;
pb->show ();
return 0;
}
运行后的打印结果是______。
第1题:
有以下程序: #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; p
A.XY
B.YX
C.X
D.Y
第2题:
若有以下程序: #include<iostream> using namespace Std; Class Base {public: Base() {x=0;} int x;}; class Derivedl:virtua1 public Base {public: Derived1() {x=10;}}; class Derived2:virtual1 public Base {public: Derived2()
A.20
B.30
C.10
D.0
第3题:
第4题:
有以下程序#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
第5题:
有以下程序 #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