>the syntax suggests that it IS a type-cast.
Yeah, thats why I wanted to point out that it isn't a cast. As mentioned, CString has explicitly defined a LPCTSTR operator. That makes it possible to do calls like:
Code:
void someFunc(LPCTSTR s)
{
...
}
...
CString someCString;
someFunc(someCString)
Ie, its invoked whenever you treat the CString as a LPCTSTR. The (LPCTSTR) cast-like thingie, is really just a way to tell the CString "Im expecting a LPCTSTR" and thus the operator is invoked.
It would not be possible to do is the CString handn't defined that operator.
>Isn't that line of code essentially just type-casting the pointer
What pointer? Note that your dealing with a CString, not a pointer to a CString.
This would be a cast
Code:
CString s;
LPCTSTR s2 = (LPCTSTR) &s; // Very bad cast!
that'd be quite wrong to perform, because a pointer to a CString
is not a LPCTSTR. Ie the compiler thinks s2 is pointing to a LPCTSTR, when its infact pointing to a CString. It will go *kaboom*...
/Per
"It was a work of art, flawless, sublime. A triumph equaled only by its monumental failure."