2
CComSafeArray<BYTE> arr;
arr.Add(0x00);

Error -> C2668: 'ATL::CComSafeArray::Add' : ambiguous call to overloaded function

I can add any value but can't add 0 , why?

btw currently I'm doing

const byte zero = 0x00;
arr.Add(zero);

but I don't understand the reason why I can't just add 0

4

1 回答 1

2

添加元素的方法是:

HRESULT Add(_In_ const T& t, _In_ BOOL bCopy = TRUE) // 0x00 as zero for t

也就是说,您的论点应该是 type const BYTE&。但是,还有另一种Add方法可以接受您的零参数:

HRESULT Add(_In_ const SAFEARRAY *psaSrc) // 0x00 as NULL for pasSrc

因此存在歧义,您应该通过适当地转换您的论点来解决它:

CComSafeArray<BYTE> arr;
arr.Add((const BYTE&) 0x00);
于 2014-04-07T05:54:13.917 回答