3

I am trying to inherit from and extend a structure defined in MIDL. I used the same syntax as for interface inheritance i.e

typedef struct stDBIBinVarDataEx
 {
   float x;
 } MYSTRUCT ;

struct struct2 : MYSTRUCT
 {
   float y;
 };

but the compiler generates errors.

1 Answer 1

3

You can't. MIDL isn't a C++ compiler.

You CAN declare struct2 as containing MYSTRUCT:

struct struct2
{
    MYSTRUCT mystruct;
    float y;
}

It's not quite the same thing but it's probably as close as you're going to get.

1
  • This approach may come handy but is problematic when you want to pass more specialized structures to interfaces, e.g. Bar([in] MYSTRUCT s); cannot be called with an struct2-instance (obviously).
    – Carsten
    May 30, 2016 at 11:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.