2010-04-06 77 views
3

我想从MIDL中定义的结构继承和扩展。我使用与接口继承相同的语法,例如MIDL中的结构继承

typedef struct stDBIBinVarDataEx 
{ 
    float x; 
} MYSTRUCT ; 

struct struct2 : MYSTRUCT 
{ 
    float y; 
}; 

但编译器生成错误。

回答

3

你不能。 MIDL不是C++编译器。

你可以声明struct2含有MYSTRUCT:

struct struct2 
{ 
    MYSTRUCT mystruct; 
    float y; 
} 

这是不太一样的东西,但它可能是接近你会得到。

+0

这种方法可能会派上用场,但如果您想将更专业的结构传递给接口,则会产生问题。 'Bar([in] MYSTRUCT s);'不能用'struct2'-实例调用(显然)。 – Carsten 2016-05-30 11:07:48