The Artima Developer Community
Sponsored Link

Heron-Centric: Ruminations of a Language Designer
C++ Delegation and Dynamic Inheritance
by Christopher Diggins
August 17, 2005
Automating the delegation of implementation of an interface to an expression.


For some time I have looked for a way to have automated delegation and dynamic inheritance in C++ without introducing extra pointers in a class.

Delegation is a technique of forwarding the implementation of a particular interface to a field or expression. Typically in C++ this is only done manually, i.e.:

  class MyClass {
    FuBar fb;
    void Fu() { fb.Fu(); }
    void Bar() { bar.Bar(); }

The problem with this is that it is horribly tedious, and tedium always screams at me "there has got to be a better way". Well I have found a way to automate delegations, without introducing extra pointers into a class., I've described it briefly in this article at CodeProject.

For those casually interested, I did this so I can reduce the work performed by HeronFront the Heron to C++ translator. This technique lets me do some really cool stuff, without having to introduce type-checking and template expansion into the translator.

Talk Back!

Have an opinion? Readers have already posted 5 comments about this weblog entry. Why not add yours?

RSS Feed

If you'd like to be notified whenever Christopher Diggins adds a new entry to his weblog, subscribe to his RSS feed.

About the Blogger

Christopher Diggins is a software developer and freelance writer. Christopher loves programming, but is eternally frustrated by the shortcomings of modern programming languages. As would any reasonable person in his shoes, he decided to quit his day job to write his own ( ). Christopher is the co-author of the C++ Cookbook from O'Reilly. Christopher can be reached through his home page at

This weblog entry is Copyright © 2005 Christopher Diggins. All rights reserved.

Sponsored Links


Copyright © 1996-2018 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use