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.

sreyas
  • 133
  • 1
  • 8

1 Answers1

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.

Larry Osterman
  • 16,086
  • 32
  • 60
  • 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 '16 at 11:07