why const CString & host cannot use the GetBuffer() function?
why const CString & host cannot use the GetBuffer() function?
code:
if(inet_addr( host.GetBuffer(0) )==INADDR_NONE)
{ .....}
error:
C2663: “ATL::CSimpleStringT<BaseType>::GetBuffer” : 2 个重载没有“this”指针的合法转换
with
[
BaseType=TCHAR
]
help me , thanks!
Re: why const CString & host cannot use the GetBuffer() function?
Quote:
2 个重载没有“this”指针的合法转换
Could you translate it?
Re: why const CString & host cannot use the GetBuffer() function?
Cast to const pointer:
Code:
if(inet_addr( (LPCTSTR)host.GetBuffer(0) )==INADDR_NONE)
Re: why const CString & host cannot use the GetBuffer() function?
Quote:
Originally Posted by Alex F
Cast to const pointer:
Code:
if(inet_addr( (LPCTSTR)host.GetBuffer(0) )==INADDR_NONE)
Hmm, in this case you do NOT need GetBuffer() at all!:
Code:
if(inet_addr( (LPCTSTR)host)==INADDR_NONE)
Re: why const CString & host cannot use the GetBuffer() function?
I see even the cast (LPC[T]STR) is not needed. The CString::operator LPCTSTR() will be invoked as "conversion" operator automatically.
Re: why const CString & host cannot use the GetBuffer() function?
You simply can't call GetBuffer(), because GetBuffer() is not a const method, and since your object is const, you can't. For objects that are declared as const, you can only call constant member functions. This ensures that the constant object is never modified.
Re: why const CString & host cannot use the GetBuffer() function?
2 个重载没有“this”指针的合法转换
means two overloadings don't have "this"pointer's legal conversion
I see ,thank you very much!