Re: casting to a derived class

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Kj,

You are describing another implementation of a visitor, which
would work if the OP has polymorph methods, which he has not
( he has DoThis() and DoThat())

Creational Patterns have nothing to do with the problem at hand, sorry

Rick

Thats

On 17 May 2005 20:29:19 -0700, "KJ" <n_o_s_p_a__m@xxxxxxxx> wrote:

>I'm not Rick, but Visitor is a design pattern that you don't need here.
>You need an interface. Just cast any of the derived classes to the
>interface, which they all implement. The actual implementation is what
>gets called at runtime, which is unique to every class that implements.
>
>
>You could even also use a factory method (another Design Pattern) to
>generate the specific types of instances you want via a string. But I
>wouldn't do that here.

.


Quantcast