明明在头文件中定义了类成员变量,使用时非说未定义
//不好意思只有十九分了//头文件***************************************
#pragma once
#include "string"
#include "list"
using namespace std;
struct stTimer //结构体,保存定时器的信息
{
unsigned id;
unsigned timeElapse;//间隔时间
unsigned timeLastRun;
int iParam;//预留参数
std::string strParam;//预留参数
bool bDel; //是否要被删除
stTimer() { //初始化
timeElapse = 0;
timeLastRun = 0;
id = 0;
iParam = 0;
bDel = false;
}
};
typedef list<stTimer> stTimerList;
typedef list<stTimer>::iterator itTimerList;
class cMyTimer
{
public:
cMyTimer();
~cMyTimer();
//添加定时器
void AddTimer(unsigned timeId, unsigned timeElapse, int param = 0, char *p = NULL);
//删除定时器
void DeleteTimer(unsigned id);
private:
//***********就是下面这个变量
stTimerList m_timerList;
};
//源文件****************************************************************************************
//#include"stdafx.h"
//#include"cMyTimer.h"
//#include"windows.h"
#include "stdafx.h"
#include "cMyTimer.h"
#include "windows.h"
#include "process.h"
//using namespace std;
cMyTimer::cMyTimer() {
}
cMyTimer::~cMyTimer() {
}
void AddTimer(unsigned timeId, unsigned timeElapse, int param, char *p) {
//构造一个结构体,加到list中
//timeElapse!=0,==0就returm;
if (timeElapse == 0)
{
return;
}
stTimer stTimertemp;
stTimertemp.bDel = false;
stTimertemp.id = timeId;
stTimertemp.iParam = param;
stTimertemp.timeElapse = timeElapse;
stTimertemp.timeLastRun = GetTickCount();//当前时间
//***************就是下面使用时非说未定义
m_timerList.push_back(stTimertemp);
}
void DeleteTimer(unsigned id) {
//for(itTimerList m_timerlist.
}
int main()
{
char*p;
AddTimer(1, 2, 3, p);
}