2

I have various classes that use multiple inheritance, i.e.:

class A
{
};

class B
{
};

class C : public A, public B
{
};

Single inheritance in an ABI file is possible using the base layer as follows (assuming we only inherit from A):

{
  "name": "C"
  "base": "A",
  "fields": []
}

My question is, how do we inherit from both A and B within the ABI file?

1 Answer 1

1

So I have been in discussion with Todd Fleming from B1, and he said that this is currently not possible.

The solution is to include the other classes as members within the concrete class:

class A
{
};

class B
{
};

class C
{
  A foo;
  B bar;
};

The enhancement to the ABI file will not be implemented unless there is a large demand for it. So if this is a feature you want to see, be sure to let B1 know by writing in this Github issue: https://github.com/EOSIO/eos/issues/6576


Source

Eos Developers Channel: https://t.me/joinchat/Esi1OkPktgcFeJ3Lmlcrqg

Phillip Hamnett - EOS42, [09.01.19 13:25] Hey everyone, quick question: Does anyone know if multiple inheritance is supported for structs in ABI files?

Todd Fleming, [09.01.19 14:04] [In reply to Phillip Hamnett - EOS42] It’s not

Phillip Hamnett - EOS42, [09.01.19 14:08] [In reply to Todd Fleming] I suppose the general question would be, is it planned that eventually mulitple inheritance will be supported, and if so is there a rough timeline?

Todd Fleming, [09.01.19 14:10] [In reply to Phillip Hamnett - EOS42] It’s not. You can embed structs in other structs instead.

Phillip Hamnett - EOS42, [09.01.19 14:12] [In reply to Todd Fleming] You mean like this?

class A 
{   
  class B   
  {   
  } 
}

Todd Fleming, [09.01.19 14:13]

class A {...}; 
class B { A bar; };
Todd Fleming, [09.01.19 14:15] It takes updating 3 abi serializers, eosio-cpp’s generator, plus it affects community-written abi serializers.

Todd Fleming, [09.01.19 14:16] We have to see a very large advantage before we update the abi format because of the amount of coordination it takes

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.