求教一个CString类Format函数的问题
在VC++中自己编了一个函数如下:
static BOOL DeviceFind(DWORD dwVendorId, DWORD dwDeviceId, WD_PCI_SLOT *pSlot)
{
DWORD dwStatus;
DWORD i, dwNumDevices;
BZERO(scanResult);
dwStatus = WDC_PciScanDevices(dwVendorId, dwDeviceId, &scanResult);
dwNumDevices = scanResult.dwNumDevices; //Record the number of device
CString str;
str.Format = ("Found %ld matching device.",dwNumDevices);
AfxMessageBox(_T(str));
return TRUE;
}
其中斜体的那一行编译时报错,有两个错误:
TestDlg.cpp(41): error C2475: “ATL::CStringT<BaseType,StringTraits>::Format” : 构造一个指向成员的指针需要显式使用 address-of 运算符('&')和限定名
with
[
BaseType=char,
StringTraits=StrTraitMFC<char>
]
TestDlg.cpp(41): error C2659: “=” : 作为左操作数的重载函数
不知道是为什么,请高水平指教一下,谢谢