
Specifying CString Formal Parameters
For most functions that need a string argument, it is best to specify the formal parameter in the function prototype as a const pointer to a character (LPCTSTR) instead of a CString. When a formal parameter is specified as a const pointer to a character, you can pass either a pointer to a TCHAR array, a literal string ["hi there"], or a CString object. The CString object will be automatically converted to an LPCTSTR. Any place you can use an LPCTSTR, you can also use a CString object.
You can also specify a formal parameter as a constant string reference (that is, constCString&) if the argument will not be modified. Drop the const modifier if the string will be modified by the function. If a default null value is desired, initialize it to the null string [""], as shown below:
void AddCustomer(const CString& name, const CString& address,
const CString& comment = _T(""));
For most function results, you can simply return a CString object by value.