Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All
Important This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here.

string (C++) 

Indicates that the one-dimensional char, wchar_t, byte (or equivalent) array or the pointer to such an array must be treated as a string.


The string C++ attribute has the same functionality as the string MIDL attribute.

The following code shows how to use string on an interface and on a typedef:

// cpp_attr_ref_string.cpp
// compile with: /LD
#include "unknwn.h"
[export, string] typedef char a[21];
[dispinterface, restricted, uuid("00000000-0000-0000-0000-000000000001")]
__interface IFireTabCtrl
   [id(1)] HRESULT Method3([in, string] char *pC);

Attribute Context

Applies to

Array or pointer to an array, interface parameter, interface method



Required attributes


Invalid attributes


For more information about the attribute contexts, see Attribute Contexts.

Community Additions

© 2015 Microsoft