在C++中,有时候,如果使用了标准命令空间 using namespace std;
就不能包含 <window.h> 这个头文件,但是, GetTickCount() 这个函数就必须包含这个头文件,那么,有没有什么方法可以实现呢?
可以这样写:
#include <time.h>
static unsigned long GetTickCount(void)
{
return (unsigned long)time(NULL);
}
参考: 【C/C++时间系列】通过time()函数获取时间戳_natpan的博客-CSDN博客_c++获取时间戳
如果是纯控制台,就这样写:
#include <iostream>
#define _AFXDLL
#include <afx.h>
using namespace std;
void main(void)
{
unsigned long TickOld = GetTickCount();
}
或者:
#include <iostream>
#include <Windows.h>
using namespace std;
void main(void)
{
unsigned long TickOld = GetTickCount();
}