OSNews article about C++09 degenerates into C++ vs. D discussion

Boris Kolar boris.kolar at globera.com
Mon Nov 20 06:19:45 PST 2006


== Quote from Walter Bright (newshound at digitalmars.com)'s article
> Have you considered using structs instead of classes? They are allocated
> on the stack.

Yes, but I need to override things too. There is often some functionality
that I need to keep abstract. I actually use structs quite often. Sometimes
I use structs in combination with interfaces, like:

  struct Foo {
    interface Model {
      void foo();
    }
    static Foo opCall(Model foo) {
      Foo result;
      result._foo = foo;
      return result;
    }
    void foo() {
      if (_foo) _foo.foo();
    }
    private Model _foo;
  }

... but that doesn't solve the problem, because there are no
destructors in structs (and it's too verbose for my taste too).



More information about the Digitalmars-d mailing list