共用方式為


case (C++)

搭配 switch_type 屬性上等位

[ case( 
   value 
) ]

參數

  • 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

可重複

必要的屬性

None

無效的屬性

None

如需有關屬性內容的詳細資訊,請參閱屬性內容

請參閱

其他資源

IDL 屬性

Typedef、Enum、Union 和 Struct 屬性

類別屬性

Attributes Samples