编译器错误 C3807

“type”: 具有 ComImport 特性的类不能从“type2”派生,只允许派生接口实现

派生自 ComImportAttribute 的类型只能实现接口。

示例

下面的示例生成 C3807。

// C3807.cpp
// compile with: /clr /c
ref struct S {};
interface struct I {};

[System::Runtime::InteropServices::ComImportAttribute()]
ref struct S1 : S {};   // C3807
ref struct S2 : I {};