Classes. C++ to D
Meta via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Sun May 3 10:46:53 PDT 2015
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 std::string("bar");
> }
> };
>
> class C : public A, public B {};
>
> int main () {
>
> C c;
>
> std::cout << c.a() << c.b() << std::endl;
>
> return 0;
> }
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.
More information about the Digitalmars-d-learn
mailing list