下面程序的结果是 #include<iostream.h> class A { public: A(){cout<<"construtA" <<endl;} virtual ~A() {cout << "destructA" <<endl;}}; class B:public A { }; class C:public A { }; class D:public B,public C { }; void main() { Dd;}
A.constructA
B.constructA
C.constmctA
D.constmctA destructA constructA constmctA constructA destructA constructA constructA destructA destructA constructA destructA dest
第1题:
下列程序的运行结果是______。
include<iostream.h>
class Base
{
public:
void f(int x){cout<<“Base:”<<x<<endl;}
);
class Derived:public Base
{
public:
void f(char*str){cout<<“Derived:”<<str<<endl;}
};
void main(void)
{
Base*pd=ne
第2题:
下面程序输出的结果为 #include"iostream.h” class A { public: A(){cout<<"CLASSA"<<endl;} ~A() {} }; class B:public A { public: B(){cout<<"CLASS B"<<endl;} ~B(){} }; void main() { A*p; p=new B;
A.CLASS A CLASS B CLASS B CLASS B
B.CLASS A CLASS B CLASS A CLASS B
C.CLASS A CLASS B CLASS B
D.CLASS A CLASS B
第3题:
以下程序的执行结果是______.
include<<iostream.h>
c1ass A
{
public:
virtual void funl () { cout<<"A fun1"<<endl;}
virtual void fun2 () {cout<<"A fun2"<<endl;
void fun3 () {cout<<" A fun 3 "<<endl:)
void fun4 () {cout<<" A fun4 "<<endl:}
第4题:
以下程序的执行结果是______。
include<iostream.h>
class base
{
public:
virtual void who(){cout<<"base class"<<endl:}
};
class derrvel:public base
{
public:
void who(){cout<<"derivel class"<<endl:}
};
class derive2;public base
{
public:
void who() {cout<<"derive2 class"<<endl;}
};
void main()
{
base obj1,*P;
derive1 obj2;
derive2 obj3:
p=&obj1;
p->who();
p=&obj2:
p->who();
p=&obj3;
p->who();
}
第5题:
下面程序的运行结果是( )。 #include<iostream> using namespace std; class A { public: virtual~A() { cout<<"call A::~A()"<<endl;} }; class B:public A { char * p; public: B(int i) { p=new char[i];} ~B() { delete(p); cout<<"call B::~B()"; } }; void main() { A * a=new B(8); delete a; }
A.call B::~B()call A::~A()
B.call B::~B()
C.call A::~A()
D.call A::~A()call B::~B()