import std.stdio;
import std.string;

I've been reading a bit about multi-inheritance in D, but I have to use interface like C # to use multiple inheritance, but I have the code in C ++ that I've been testing to understand how it would be possible to implement multi-inheritance constructor despite seemingly It does not represent many things so I changed the code to use interface but how would I do so I could use the constructor in the same way as such a C ++ code?

Test1,2,3 would be the name of the class constructors in C ++ how to port completely to D so that it works the same way?

import std.stdio;
import std.string;

class Test1
{
 protected:
  std::string _msg1;
   public:
   Test1( std::string msg1 ):
 _msg1( msg1 ){}
};

class Test2
{
 protected:
  std::string _msg2;
   public:
   Test2( std::string msg2 ):
 _msg2( msg2 ){}
};

class Test3
{
 protected:
  std::string _msg3;
   public:
   Test3( std::string msg3 ):
 _msg3( msg3 ){}
};

class Test4: public Test1, public Test2, public Test3
{
 std::string _msg4;
  public:
Test4( std::string msg1, std::string msg2 , std::string msg3, std::string msg4 ):
  Test1( msg1 ), Test2( msg2 ), Test3( msg3 ), _msg4( msg4 ){ }
 void show();
};

void Test4::show()
{
std::cout << this->_msg1 << this->_msg2 << this->_msg3 << this->_msg4 << "\n\n";
}

int main()
{
 Test4 teste("\n\tTeste1 ","Teste2 ","Teste3 ","Teste4");
  teste.show();
 return 0;
}

Reply via email to