case (C++)

使用 switch_type 属性。 联合

[ case( 
   value 
) ]

参数


  • 要提供处理的一个可能的输入值。 的类型可为下列类型之一:

    • int

    • char

    • boolean

    • enum

    或这样的类型标识符。

备注

用例 C++ 特性具有与 用例 MIDL 属性相同。 此属性仅用于 switch_type 属性。

示例

下面的代码演示 用例 属性的用法:

// cpp_attr_ref_case.cpp
// compile with: /LD
#include <unknwn.h>
[export]
struct SizedValue2 {
   [switch_type(char), switch_is(kind)] union {
      [case(1), string]
          wchar_t* wval;
      [default, string]
          char* val;
   };
    char kind;
};
[module(name="ATLFIRELib")];

要求

属性上下文

适用对象

或 struct的成员

可重复

必需的特性

无效的特性

有关属性上下文的更多信息,请参见 属性上下文

请参见

其他资源

IDL 特性

Typedef、Enum、Union 和 Struct 特性

类特性

Attributes Samples