Compartilhar via


CFixedStringT Class

This class represents a string object with a fixed character buffer.

template< class StringType, int t_nChars >  
class CFixedStringT : private CFixedStringMgr, public StringType

Parameters

  • StringType
    Used as the base class for the fixed string object and can be any CStringT-based type. Some examples include CString, CStringA, and CStringW.

  • t_nChars
    The number of characters stored in the buffer.

Members

Public Constructors

Name

Description

CFixedStringT::CFixedStringT

The constructor for the string object.

Public Operators

Name

Description

CFixedStringT::operator =

Assigns a new value to a CFixedStringT object.

Remarks

This class is an example of a custom string class based on CStringT. Although quite similar, the two classes differ in implementation. The major differences between CFixedStringT and CStringT are:

  • The initial character buffer is allocated as part of the object and has size t_nChars. This allows the CFixedString object to occupy a contiguous memory chunk for performance purposes. However, if the contents of a CFixedStringT object grows beyond t_nChars, the buffer is allocated dynamically.

  • The character buffer for a CFixedStringT object is always the same length (t_nChars). There is no limitation on buffer size for CStringT objects.

  • The memory manager for CFixedStringT is customized such that sharing of a CStringData object between two or more CFixedStringT objectsis not allowed. CStringT objects do not have this limitation.

For more information on the customization of CFixedStringT and memory management for string objects in general, see Memory Management and CStringT.

Inheritance Hierarchy

IAtlStringMgr

StringType

CFixedStringMgr

CFixedStringT

Requirements

Header: cstringt.h

See Also

Reference

CStringT Class

Hierarchy Chart

Other Resources

ATL/MFC Shared Classes