smallcar.cpp
来自「是一款车库模拟控制系统,可以实现对当前车库存车状态的实时描述.」· C++ 代码 · 共 48 行
CPP
48 行
// SmallCar.cpp: implementation of the CSmallCar class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "garage.h"
#include "SmallCar.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
//#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CSmallCar *CSmallCar::p_free=NULL;
int CSmallCar::getCharge(){
COleDateTimeSpan timespan(0,0,1,0);
timespan=COleDateTime::GetCurrentTime()-inTime;
int fee=(timespan.GetDays()*24*6+timespan.GetHours()*6+timespan.GetMinutes()/10+1)*unitPrice;
if(timespan.GetMinutes()==0||timespan.GetSeconds()==0)
fee-=unitPrice;
return fee;
}
void *CSmallCar::operator new(size_t size)
{
CSmallCar * p;
if(p_free==NULL)
{
p_free=(CSmallCar*)new char[size*NUM];
for(p=p_free;p!=p_free+NUM-1;p++)
p->next=p+1;
p->next=NULL;
}
p=p_free;
p_free=p_free->next;
memset(p,0,size);
return p;
}
void CSmallCar::operator delete(void *p)
{
((CSmallCar*)p)->next=p_free;
p_free=(CSmallCar*)p;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?