如何创建默认函数参数作为具有初始化成员的结构?
#if defined(MIDL_PASS)
typedef struct _LARGE_INTEGER {
#else // MIDL_PASS
typedef union _LARGE_INTEGER {
struct {
DWORD LowPart;
LONG HighPart;
} DUMMYSTRUCTNAME;
struct {
DWORD LowPart;
LONG HighPart;
} u;
#endif //MIDL_PASS
LONGLONG QuadPart;
} LARGE_INTEGER;
LARGE_INTEGER g_l;
void journal(void *foo, const int bar, const LARGE_INTEGER& offsetToHistory = g_l )
{
return;
}
int main()
{
g_l.QuadPart = 0;
LARGE_INTEGER li;
li.QuadPart = 0;
journal(NULL, 15, const_cast<LARGE_INTEGER&>(li));
//I want this the below line to work as well the above.
//journal(NULL, 15);
}
如何在不使用全局变量“g_l”的情况下实现此目的。实际上,它在构造函数原型中使用,因此我们不能使用全局变量。 我也不想重载构造函数。