[Klug-general] c++ design pattern question

James Morris jwm.art.net at gmail.com
Mon Oct 14 11:23:00 UTC 2013


i've created an abstract base class to store object representations for the
ui.

each object consists of any number of elements of which there are three
classes of.

so I have created three ui element classes derived from the common abstract
class.

however the three classes don't have so much in common when it comes to
methods, return types, arguments, data, to make virtual methods seem quite
the right way to go.

so I store the element type in the base class and do a switch on that and
then perform a static_cast to obtain the correct object type to access its
methods. but i'm not really convinced about this either.

I could go with the virtual methods and they could return error codes when
called on the wrong ui element type.

just wondering if anyone knows the name of the design pattern that solves
this one so I can go read up on it?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.lug.org.uk/pipermail/kent/attachments/20131014/00c432aa/attachment.html>


More information about the Kent mailing list