共用方式為


CSimpleStringT::operator PCXSTR

直接存取在 CSimpleStringT 物件中的字元當成 C++. 格式的樣式。

operator PCXSTR( ) const throw( );

傳回值

字串資料的一個字元指標。

備註

不會複製任何字元;只有指標傳回。 此運算子時請小心。 如果您變更 CString 物件,才能取得字元指標之後,您可能會導致無效指標的記憶體重新配置。

範例

下列範例示範如何使用 CSimpleStringT::operator PCXSTR

// If the prototype of a function is known to the compiler,
// the PCXSTR cast operator may be invoked implicitly.

CSimpleString strSports(L"Soccer is Best!", pMgr);
WCHAR sz[1024];

wcscpy_s(sz, strSports);

// If the prototype isn't known or is a va_arg prototype,
// you must invoke the cast operator explicitly. For example,
// the va_arg part of a call to swprintf_s() needs the cast:

swprintf_s(sz, 1024, L"I think that %s!\n", (PCWSTR)strSports);

// While the format parameter is known to be an PCXSTR and
// therefore doesn't need the cast:

swprintf_s(sz, 1024, strSports);

// Note that some situations are ambiguous. This line will
// put the address of the strSports object to stdout:

wcout << strSports;

// while this line will put the content of the string out:

wcout << (PCWSTR)strSports;   

需求

Header: atlsimpstr.h

請參閱

參考

CSimpleStringT 類別