Boost logo

Boost Users :

From: Johan Nilsson (r.johan.nilsson_at_[hidden])
Date: 2006-10-26 04:05:33


Wu Yinghui, Freddie wrote:

[snip]

>
> The situation is like this: In the pseudo-code you provided, DoWork()
> function is declared in the Base class, and is overridden by Derived1
> and Derived2, with a fixed number of arguments. My problems is that,
> my base class cannot predict the exact number of parameters that a
> derived class may have. (A derived class may have 10 parameters,
> while another may have none.) So it looks a little bit out-of-shape
> in terms of the OO programming style I'm familiar with if I'm going
> to provide overloads of DoWork() for all the possible parameters used
> by all derived classes (not to mention the undesirable dependency
> introduced).

In order to know which parameters to send through the interface, you'll have
to know the exact subclass? Sorry, that doesn't make sense.

What's the real problem you are trying to solve - could Boost.Variant +
static_visitor (or some other variant on the Visitor pattern) help?

/ Johan


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net