Re: Classes. C++ to D

2015-05-03 Thread Meta via Digitalmars-d-learn
On Sunday, 3 May 2015 at 17:35:42 UTC, Dennis Ritchie wrote: Hi, How can I rewrite this code to the D? - #include string #include iostream class A { public: std::string a() { return std::string(foo); } }; class B { public: std::string b(){ return

Re: Classes. C++ to D

2015-05-03 Thread Dennis Ritchie via Digitalmars-d-learn
On Sunday, 3 May 2015 at 17:46:54 UTC, Meta wrote: This is not really doable right now in D. You can forward the function calls to a and b easily enough, but you can't inherit from more than one class. Once the multiple alias this patch gets merged you will be able to do this in D. On

Re: Classes. C++ to D

2015-05-03 Thread QAston via Digitalmars-d-learn
On Sunday, 3 May 2015 at 17:35:42 UTC, Dennis Ritchie wrote: Hi, How can I rewrite this code to the D? - #include string #include iostream class A { public: std::string a() { return std::string(foo); } }; class B { public: std::string b(){ return

Re: Classes. C++ to D

2015-05-03 Thread Adam D. Ruppe via Digitalmars-d-learn
I'd make class A and class B into mixin templates instead. mixin template A { string a() { return foo; } } mixin template B { string b() { return bar; } } class C { mixin A; mixin B; } If you still need class A and class B, just make a class that mixes in the template for them

Classes. C++ to D

2015-05-03 Thread Dennis Ritchie via Digitalmars-d-learn
Hi, How can I rewrite this code to the D? - #include string #include iostream class A { public: std::string a() { return std::string(foo); } }; class B { public: std::string b(){ return std::string(bar); } }; class C : public A, public B {};