下面程序运行时输出结果为【 】。
include<iostream.h>
include<malloc.h>
class Rect
{
public:
Rect(int1,int w)(length=1;width=w;)
void Print(){cout<<"Area:"<<length *width<<endl;)
void *operator new(size-t size){return malloc(size);}
void operator delete(void *p){free(p)
private:
int length,width;
};
void main()
{
Rect*p;
p=new Rect(5,4);
p->Print();
delete p;
}
第1题:
下面程序输出的结果为 #include"iostream.h" class A { public: A(){cout<<"CLASSA"<<endl;} ~A() {} }; class B:public A { public: B(){cout<<"CLASSB"<<endl;} ~B() {} }; void main() { A * p; p=new B; B *q; q=new B; }
A.CLASS A CLASS B
B.CLASS A CLASS B CLASS B
C.CLASS A CLASS B CLASS A CLASS B
D.CLASS A CLASS B CLASS B CLASS B
第2题:
下面程序输出的结果为( )。 #include"iostream.h" classA {public: A(){cOUt<<"CLASSA"<<endl;} ~A(){}}; ClaSSB:publicA {public: B(){cout<<"CLASSB"<<endl;} ~B(){}}; voidmain() {A*P; P=newB: B*q: q=newB;}
A.CLASSA
B.CLASSA CLASSBCLASSB CLASSB
C.CLASSA
D.CLASSA CLASSBCLASSB CLASSACLASSB CLASSBCLASSB
第3题:
下面程序输出的结果为( )。 #inClUde”iostream.h” Class A {public: A(){cout<<“CLASS A”<<endl;} ~A()<)}; class B:public A {public: B(){cout<<”CLASSB”<<endl;} ~B(){}}; void main() {A*p; p=new B; B *q; q=new B;}
A.CLASS A CLASS B
B.CLASS A CLASS B CLASS B
C.CLASS A ClASS B
D.CLASS A CLASS B CLASS A CLASS B CLASS B CLASS B
第4题:
下面程序输出的结果为
#include"iostream.h"
class A
{
public:
A( ){cout<<"CLASS A"<<endl;}
~A( ){}
};
class B:public A
{
public:
B( ){cout<<"CLASS B"<<endl;}
~B( ){}
};
void main( )
{
A*p;
p=new B;
B *q;
q=new B;
}
A.CLASS A CLASS B
B.CLASS A CLASS B CLASS B
C.CLASS A CLASS B CLASS A CLASS B
D.CLASS A CLASS B CLASS B CLASS B
第5题:
下面程序输出的结果为 #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