下面程序运行时输出结果为______。
include<iostream.h>
include
class Rect
{
public:
Rect(int l, int w){length=l; width=w;)
void Print(){cout<<"Area:"<<length*width<<end1;}
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> class A { int num; public: A(int){num=i;} A(ABm){num=a.num++;} void print(){cout<<num;} }; void main() { Aa(1),b(a); a.print(); b.print(); }
A.11
B.12
C.21
D.22
第3题:
下面程序输出的结果为 #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
第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" 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