Aracılığıyla paylaş


CSimpleStringT::operator =

Assigns a new value to a CSimpleStringT object.

CSimpleStringT& operator =(
   PCXSTR pszSrc 
);
CSimpleStringT& operator =(
   const CSimpleStringT& strSrc 
);

Parameters

  • pszSrc
    A pointer to a null-terminated string.

  • strSrc
    A pointer to an existing CSimpleStringT object.

Remarks

If the destination string (the left side) is already large enough to store the new data, no new memory allocation is performed. Note that memory exceptions may occur whenever you use the assignment operator because new storage is often allocated to hold the resulting CSimpleStringT object.

Example

The following example demonstrates the use of CSimpleStringT::operator =.

CSimpleString s1(pMgr), s2(pMgr);  // Empty CSimpleStringT objects

s1 = _T("cat");            // s1 = "cat"
ASSERT(_tcscmp(s1, _T("cat")) == 0);

s2 = s1;               // s1 and s2 each = "cat"
ASSERT(_tcscmp(s2, _T("cat")) == 0);

s1 = _T("the ") + s1;      // Or expressions
ASSERT(_tcscmp(s1, _T("the cat")) == 0);

s1 = _T("x");              // Or just individual characters
ASSERT(_tcscmp(s1, _T("x")) == 0);   

Requirements

Header: atlsimpstr.h

See Also

Reference

CSimpleStringT Class

CSimpleStringT::CSimpleStringT

Other Resources

CSimpleStringT Members