-
大小: 2KB文件類型: .cpp金幣: 1下載: 0 次發布日期: 2021-06-04
- 語言: C/C++
- 標簽: UserApp.cpp??
資源簡介
Package-delivery services, such as FedEx?, DHL? and UPS?, offer a number of different shipping options, each with specific costs associated. Create an inheritance hierarchy to represent various types of packages.
代碼片段和文件信息
#include
#include
using?namespace?std;
class?Shape
{
public?:
virtual?void?draw(){
cout<<“drow?Shape!“< }
};
class?Point
{
public:
double?x;
double?y;
};
class?Triangle:public?Shape
{
public:
Point?a;
Point?b;
Point?c;
void?draw(){
cout<<“Triangle!“< cout<<“(“< cout<<“(“< cout<<“(“< };
class?Square:public?Shape
{
public:
Point?v1;
double?width;
void?draw(){
cout<<“Square!“< };
};
class?Rectangle:public?Shape
{
public:
Point?a;
Point?b;
double?width;
double?height;
void?draw(){
cout<<“Rectangle!“< };
};
class?Graphics:public?Shape
{
public?:
vector?shapes;
void?add(Shape?*shape){
shapes.push_back(shape);
};
void?draw(){
for(int?i=0;i {
Shape?*shape=shapes[i];
shape-
- 上一篇:C++實現的旅行商問題
- 下一篇:高仿QQ截圖
評論
共有 條評論