求大神解释一下各个步骤是什么意思干什么的,小弟就这些分了,帮帮忙吧,万分感谢

#include"stdafx.h"#include<iostream>#include<string>usingnamespacestd;classQuadrangle... #include "stdafx.h"
#include <iostream>
#include <string>
using namespace std;
class Quadrangle;
typedef Quadrangle* QUADPTR;
typedef void (*ACCESSFUN)(QUADPTR);
class Quadrangle
{
public:
string name;
};

class Rectangle
{
public:
string name;
Rectangle(int w=5,int h=7);
Rectangle(const Rectangle &rr);
~Rectangle();
void draw();
double area();
string what();
private:
int width,height;
};

Rectangle::Rectangle (int w,int h):name("Rectangle"),width(w),height(h){}

Rectangle::Rectangle(const Rectangle &rr)
{
width=rr.width;
height=rr.height;
}

Rectangle::~Rectangle(){}

void Rectangle::draw()
{
cout<<what()<<":width="<<width<<",height="<<height<<endl;
}

double Rectangle::area()
{
return width*height;
}

string Rectangle::what()
{
return "Rectangle";
}
class Square
{
public:
string name;
Square(int e=9);
Square(const Square &rs);
~Square();
void draw();
double area();
string what();
private:
int edge;
};
Square::Square (int e):name("Square"),edge(e){}
Square::Square(const Square &rs)
{
edge=rs.edge;
}
Square::~Square(){}
void Square::draw()
{
cout<<what()<<":edge="<<edge<<endl;
}
double Square::area()
{
return edge*edge;
}
string Square::what()
{
return "Square";
}
class Parallelogram
{
public:
string name;
Parallelogram(int w=2,int h=3);
Parallelogram(const Parallelogram &rp);
~Parallelogram();
void draw();
double area();
string what();
private:
int width,height;
};
Parallelogram::Parallelogram (int w,int h):name("Parallelogram"),width(w),height(h){}
Parallelogram::Parallelogram(const Parallelogram &rp)
{
width=rp.width;
height=rp.height;
}
Parallelogram::~Parallelogram(){}
展开
 我来答
一照澜13
2012-11-22 · 超过20用户采纳过TA的回答
知道答主
回答量:73
采纳率:0%
帮助的人:59.8万
展开全部
不知道你想问什么
这段代码定义了几个不同的图形类,仅此
更多追问追答
追问
就是问的每个步骤什么意思而已,我知道是定义图形类,而且主函数也还没给出来,就是不知道每行代码各表示什么意思
追答
include声明
using指示符
Quad类声明
typedeft 助记符

类声明
类实现

// include 声明
#include "stdafx.h"
#include
#include
// using指示符
using namespace std;
// 类声明
class Quadrangle;
// typedef定义助记符
typedef Quadrangle* QUADPTR;
typedef void (*ACCESSFUN)(QUADPTR);

// 类Quadrangle
class Quadrangle
{
public:
string name; // 公有 数据成员 name
};

// 类Rectangle,一个公有数据成员
class Rectangle
{
public:
string name; // 公有 数据成员 name
Rectangle(int w=5,int h=7); // 类构造函数
Rectangle(const Rectangle &rr); // 类构造函数 重载
~Rectangle(); // 类析构函数
void draw(); // 成员函数 draw 返回空
double area(); // 成员函数 area 返回double类型
string what(); // 成员函数 what 返回string类型
private:
int width,height; // 私有数据成员 width height
};

// 类构造函数定义
Rectangle::Rectangle (int w,int h):name("Rectangle"),width(w),height(h){}
// 类构造函数定义
Rectangle::Rectangle(const Rectangle &rr)
{
width=rr.width;
height=rr.height;
}
// 类析构函数定义
Rectangle::~Rectangle(){}
// 类成员函数定义
void Rectangle::draw()
{
cout<<what()<<":width="<<width<<",height="<<height<<endl;
}

double Rectangle::area()
{
return width*height;
}

string Rectangle::what()
{
return "Rectangle";
}
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式