std命名空间
绝大多数C++中的时间类型以及函数都只是重用了C的,仅仅是位于std命名空间中。要使用C++时间,首先要include <ctime>文件。看一下ctime文件内容,会发现包含了time.h文件。
#pragma GCC system_header
#include <bits/c++config.h>
#include <time.h>
#ifndef _GLIBCXX_CTIME
#define _GLIBCXX_CTIME 1
// Get rid of those macros defined in <time.h> in lieu of real functions.
#undef clock
#undef difftime
#undef mktime
#undef time
#undef asctime
#undef ctime
#undef gmtime
#undef localtime
#undef strftime
namespace std
{
using ::clock_t;
using ::time_t;
using ::tm;
using ::clock;
using ::difftime;
using ::mktime;
using ::time;
using ::asctime;
using ::ctime;
using ::gmtime;
using ::localtime;
using ::strftime;
} // namespace
#endif