|
-
September 21st, 2005, 10:03 AM
#1
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!
-
September 21st, 2005, 10:07 AM
#2
Re: why const CString & host cannot use the GetBuffer() function?
-
September 21st, 2005, 10:14 AM
#3
Re: why const CString & host cannot use the GetBuffer() function?
Cast to const pointer:
Code:
if(inet_addr( (LPCTSTR)host.GetBuffer(0) )==INADDR_NONE)
-
September 21st, 2005, 10:18 AM
#4
Re: why const CString & host cannot use the GetBuffer() function?
 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)
-
September 21st, 2005, 12:00 PM
#5
Re: why const CString & host cannot use the GetBuffer() function?
I see even the cast (LPC[T]STR) is not needed. The CString: perator LPCTSTR() will be invoked as "conversion" operator automatically.
-
September 21st, 2005, 01:16 PM
#6
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.
-
September 21st, 2005, 07:12 PM
#7
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!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|