bigcar.cpp

来自「是一款车库模拟控制系统,可以实现对当前车库存车状态的实时描述.」· C++ 代码 · 共 49 行

CPP
49
字号
// BigCar.cpp: implementation of the CBigCar class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "garage.h"
#include "BigCar.h"

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
//#define new DEBUG_NEW
#endif

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CBigCar *CBigCar::p_free=NULL;

int CBigCar::getCharge(){
	COleDateTimeSpan timespan(0,0,1,0);
	timespan=COleDateTime::GetCurrentTime()-inTime;
	int fee=(timespan.GetDays()*24*2+timespan.GetHours()*2)*unitPrice;
	if(timespan.GetMinutes()>0||timespan.GetSeconds()>0)
		fee+=(timespan.GetMinutes()/30+1)*unitPrice;
	return fee;
}

void *CBigCar::operator new(size_t size)
{
	CBigCar * p;
	if(p_free==NULL)
	{
		p_free=(CBigCar*)new char[size*NUM2];
		for(p=p_free;p!=p_free+NUM2-1;p++)
			p->next=p+1;
		p->next=NULL;
	}
	p=p_free;
	p_free=p_free->next;
	memset(p,0,size);
	return p;
}
void CBigCar::operator delete(void *p)
{
	((CBigCar*)p)->next=p_free;
	p_free=(CBigCar*)p;
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?