A.1/9
B.1/3
C.1
D.3
E.9
第1题
下面程序运行时输出结果为______。
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;
}
第2题
下面程序运行时输出结果为【 】。
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;
}
第3题
#include class Point { private: int x; int y; public: Point (int a,int b) { x=a; y=b; } virtual int area() {return 0;} }; class Rectangle:public Point { private: int length; int width; public: Rectangle(int a,int b,int l,int w): Point(a,b) { length=l; width=w; } virtual int area() { return length*width;} }; void disp(Point &p) { cout<< “面积是:”< void main() { Rectangle rect(3,5,7,9); Disp(rect); }
第4题
第5题
【计算题】定义一个抽象类Shape,包括属性height,抽象方法void set(double x,double y)用于赋属性值,抽象方法double area()用于求面积,定义抽象类Shape的子类长方形Rect类(定义属性length)和三角形Triangle类(定义属性bottom),重写抽象方法set(double x,double y)和double area()求它们的面积,编写测试TestShape类测试结果。
第7题
A.tie
B.rect
C.lock
D.heck
为了保护您的账号安全,请在“上学吧”公众号进行验证,点击“官网服务”-“账号验证”后输入验证码“”完成验证,验证成功后方可继续查看答案!