lzth.net
当前位置:首页 >> C++编程题(实现一个 ShApE 类层次, ShApE 为抽象基类, 以 ShApE 带有纯虚成员... >>

C++编程题(实现一个 ShApE 类层次, ShApE 为抽象基类, 以 ShApE 带有纯虚成员...

class Shape{public:Shape();virtual ~Shape();virtual void draw() = 0;virtual void resize() = 0;private:};Shape::Shape(){}Shape::~Shape(){}class Point : public Shape{public:Point();virtual ~Point();virtual void draw();virtual void resize();private:};Point::Point

#includeusing namespace std;class shape //抽象基类{protected: double s;public: shape(){s=0;} //构造函数 virtual double area() = 0; //面积计算函数(纯虚函数)};class rect:public shape //派生类矩形{private: double width; double height;public:

帮你写了一个简单的.没怎么写注释.呵呵.#include <iostream>using namespace std;const double gc_Pi = 3.14159265;class Shape{public: virtual double Area() = 0; virtual double Volumn() = 0; virtual void Display() = 0; friend ostream& operator

#include <iostream> using namespace std; class Shape //定义抽象基类 Shape { public: virtual double area() const =0; //纯虚函数 }; class Circle:public Shape { public: Circle(double r):radius(r){} //构造函数 virtual double area() const //定义虚函数

#include&lt;iostream.h&gt;#include&lt;cmath&gt;const double pi=3.14;class shape//抽象基类{public: virtual void display()=0;};class point:public shape{public: void display(){};};class circle:public point{private: double r;public: void set(double r) { r=r;}

下列shape类是一个表示形状的抽象类,area( )为求图形面积的函数,total( )则是一个通用的用以求不同形状的图形面积总和的函数.请从shape类派生三角形类(

..声明一个Shape类,具有纯虚函数getArea和getPerim,Rectangle和Circle的数据成员自己随便添加.然后就可以了撒.很简单.

class Shape { public: virtual double GetArea()=0; }; class Rectangle : public Shape { public: Rectangle(double h, double w) : height(h), width(w){} double GetArea(){ return height * width; } private: double height; double width; }; class Circle : public

abstract class shape {public shape(){} public float getperim(){return 0;} } class rectangle extends shape { private float x=0,y=0; public rectangle(float x,float y){ this.x=x; this.y=y; } public float getperim() { return 2*(x+y); } } class circle extends shape {

相关文档
网站首页 | 网站地图
All rights reserved Powered by www.lzth.net
copyright ©right 2010-2021。
内容来自网络,如有侵犯请联系客服。zhit325@qq.com