CHString::operator=

[The CHString class is part of the WMI Provider Framework which is now considered in final state, and no further development, enhancements, or updates will be available for non-security related issues affecting these libraries. The MI APIs should be used for all new development.]

The CHString assignment (=) operator reinitializes an existing CHString object with new data.

const CHString& operator =(
  const CHString& stringSrc )
throw( CHeap_Exception );

const CHString& operator =(
  WCHAR ch )
throw( CHeap_Exception );

const CHString& operator =(
  const unsigned char* psz )
throw( CHeap_Exception );

const CHString& operator =(
  LPCWSTR lpsz )
throw( CHeap_Exception );

const CHString& operator =(
  LPCSTR lpsz )
throw( CHeap_Exception );

const CHString& operator =(
  CHString *p )
throw( CHeap_Exception );

const CHString& operator =(
  char ch )
throw( CHeap_Exception );

Parameters

stringSrc, p

Assigns a CHString string to this object.

ch

Assigns a character to this object.

lpsz, psz

Assigns a NULL-terminated string to this object.

Remarks

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

Examples

The following code example shows the use of CHString::operator =:

CHString s1, s2;        // Empty CHString objects

s1 = L"cat";            // s1 = "cat"
s2 = s1;                // s1 and s2 each = "cat"
s1 = L"the " + s1;      // Or expressions
s1 = 'x';               // Or just individual characters

Requirements

Requirement Value
Minimum supported client
Windows Vista
Minimum supported server
Windows Server 2008
Header
ChString.h (include FwCommon.h)
Library
FrameDyn.lib
DLL
FrameDynOS.dll;
FrameDyn.dll

See also

CHString