On Wed, 28 Feb 2001, Angus Leeming wrote:

> > Feel free to suggest how to use a trait such that I can pass
> > the trait from a derived class to redefine the button controllers policy
> > (when the button controller is a part of the base class).
>
> Well that's not so hard. Store an abstract base ButtonControllerBase class
> with the interface and then use the trait class to instantiate it.

But how do you pass the trait?

If I have a:
        template <class BP>
        class ButtonControllerBase {
        ...
        BP policy;
        }

and I want to create an instance of it:

        class Control_Something {
        ...
        ButtonControllerBase<WhateverPolicy> my_controller;
        }

This works fine.  That's how it was originally within each dialog and then
I wanted to move the BC into your FormBase and allow a derived class to
override the default policy.  I couldn't find a way to pass the policy as
a parameter to the FormBase constructor so it could instantiate the BC. I
tried using typename but didn't get anything more than reams of
unintelligible error messages from the compiler so I guess I should read
more about it.

Anyway, if you are just going to create an instance of a BC in each
dialogs controller then converting back to a template will take a couple
of minutes followed by hours of fun converting all the other dialogs to
have separate controllers and removing BC from the FormBase.

Allan. (ARRae)

P.S. Yeah, I know I should checkout BRANCH_MVC.

Reply via email to