-
大小: 3.12KB文件類型: .zip金幣: 1下載: 0 次發(fā)布日期: 2021-02-21
- 標(biāo)簽:
資源簡(jiǎn)介
C++實(shí)戰(zhàn)源碼-適配器模式的簡(jiǎn)單應(yīng)用(入門級(jí)實(shí)例225).zip
代碼片段和文件信息
//?adapter.cpp?:?Defines?the?entry?point?for?the?console?application.
//
#include?“stdafx.h“
#include?“ioStream.h“
#include?“string.h“
typedef?char?String[30];
struct?Point
{
int?xy;
};
class?Car?{
private:
String?name; //表示名稱
????double?speed; //表示速度
public:
double?getSpeed(){
return?speed;
}
void?setSpeed(double?sp)
{
speed?=?sp;
}
char?*getName()
{
return?name;
}
void?setName(String?Name)
{
strcpy(nameName);
}
public:
virtual?void?toString()?{
????????cout?<“車名:“?<????????<“速度:“?<????}
};
class?GPS?{
????virtual?Point?getLocation()?=?0;//提供定位功能
};
class?GPSCar?:public?Car??GPS?{
public:
Point?getLocation()?{//利用汽車的速度來(lái)確定汽車的位置
????????Point?point;
point.x?=?getSpeed();
point.y?=?getSpeed();
????????return?point;
????}
????void?toString()?{
Car::toString();
????????cout?<“坐標(biāo):(“?<????}
};
?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----
?????文件????????1428??2010-10-14?19:37??adapter\adapter.cpp
?????文件????????4548??2010-10-14?19:14??adapter\adapter.dsp
?????文件?????????539??2010-10-14?19:14??adapter\adapter.dsw
?????文件?????????294??2010-10-14?19:14??adapter\StdAfx.cpp
?????文件?????????769??2010-10-14?19:14??adapter\StdAfx.h
評(píng)論
共有 條評(píng)論