CStringT inherits from CSimpleStringT Class. Advanced features, such as character manipulation, ordering, and searching, are implemented by CStringT.
Note: |
|---|
CStringT objects are capable of throwing exceptions. This occurs when a CStringT object runs out of memory for any reason.
|
A CStringT object consists of a variable-length sequence of characters. CStringT provides functions and operators using syntax similar to that of Basic. Concatenation and comparison operators, together with simplified memory management, make CStringT objects easier to use than ordinary character arrays.
Note: |
|---|
Although it is possible to create
CStringT instances that contain embedded null characters, we recommend against it. Calling methods and operators on CStringT objects that contain embedded null characters can produce unintended results.
|
By using different combinations of the BaseType and StringTraits parameters, CStringT objects can come in the following types, which are have been predefined by the ATL libraries.
If using in an ATL application:
CString, CStringA, and CStringW are exported from the MFC DLL (MFC90.DLL), never from user DLLs. This is done to prevent CStringT from being multiply defined.
Note: |
|---|
If you encountered linker errors when exporting a
CString-derived class from an MFC extension DLL in Visual C++ .NET 2002 and have applied the workaround as described in the Knowledge Base article, "Linking Errors When You Import CString-Derived Classes" (), you should remove the workaround code, because this has been fixed in Visual C++ .NET 2003. You can find Knowledge Base articles on the MSDN Library CD-ROM or at http://support.microsoft.com/support.
|
The following string types are available within MFC-based applications:
CStringT type
|
Declaration
|
|---|
CStringA
|
An ANSI character type string with CRT support.
|
CStringW
|
A Unicode character type string with CRT support.
|
CString
|
Both ANSI and Unicode character types with CRT support.
|
The following string types are available in projects where ATL_CSTRING_NO_CRT is defined:
CStringT type
|
Declaration
|
|---|
CAtlStringA
|
An ANSI character type string without CRT support.
|
CAtlStringW
|
A Unicode character type string without CRT support.
|
CAtlString
|
Both ANSI and Unicode character types without CRT support.
|
The following string types are available in projects where ATL_CSTRING_NO_CRT is not defined:
CStringT type
|
Declaration
|
|---|
CAtlStringA
|
An ANSI character type string with CRT support.
|
CAtlStringW
|
A Unicode character type string with CRT support.
|
CAtlString
|
Both ANSI and Unicode character types with CRT support.
|
CString objects also have the following characteristics:
CStringT objects can grow as a result of concatenation operations.
CStringT objects follow "value semantics." Think of a CStringT object as an actual string, not as a pointer to a string.
You can freely substitute CStringT objects for PCXSTR function arguments.
Custom memory management for string buffers. For more information, see Memory Management and CStringT.