扬州白羊山玥珑湖价格:关于c++.net2003中gethour了出错?
来源:百度文库 编辑:中科新闻网 时间:2024/10/02 18:15:17
语句:
extern "C" int EXPORT GetYime()
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
CTime t;
CString s;
int i;
t=CTime::GetCurrentTime();
s.Format("now date is %3d mouth %2d date %4d year",t.GetMonth(),t.GetDay(),t.GetYear());
AfxMessageBox(s,MB_OK,0);
i=t.GetHour;//提示错误
return i;
}
错误如下:
e:\hxm\vcnet\test\teston9\testdll\testdll.cpp(81) : error C2475: “ATL::CTime::GetHour” : 构造一个指向成员的指针需要显式使用 address-of 运算符('&')和限定名
e:\hxm\vcnet\test\teston9\testdll\testdll.cpp(81) : error C2440: “=” : 无法从“int (__thiscall ATL::CTime::* )(void) throw() const”转换为“int”
没有使该转换得以执行的上下文
为什么出错?怎么改正?请详细说明!
extern "C" int EXPORT GetYime()
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
CTime t;
CString s;
int i;
t=CTime::GetCurrentTime();
s.Format("now date is %3d mouth %2d date %4d year",t.GetMonth(),t.GetDay(),t.GetYear());
AfxMessageBox(s,MB_OK,0);
i=t.GetHour;//提示错误
return i;
}
错误如下:
e:\hxm\vcnet\test\teston9\testdll\testdll.cpp(81) : error C2475: “ATL::CTime::GetHour” : 构造一个指向成员的指针需要显式使用 address-of 运算符('&')和限定名
e:\hxm\vcnet\test\teston9\testdll\testdll.cpp(81) : error C2440: “=” : 无法从“int (__thiscall ATL::CTime::* )(void) throw() const”转换为“int”
没有使该转换得以执行的上下文
为什么出错?怎么改正?请详细说明!
应该改为
i=t.GetHour();
少了括号了。
http://msdn2.microsoft.com/zh-cn/library/system.globalization.calendar.gethour.aspx