On Thu, 17 Jun 2004 23:39:15 GMT, "Mitch Mooney"
<mr**********************@verizon.net> wrote:
[snip]
How do I return the value regardless of the data type? Ive tried using a
templated base class and could'nt complie. How can I accomplish this or
whats the work around?
You could derive a template class (or several) from your non-templated
abstract base class. I actually did this once for abstracting a
database row of data, each column having a possibly different type.
Since you often have a choice of returning a pointer or an actual
value, it might be a good idea to create two templated derived
classes, one set up for pointer semantics and the other for objects.
Your "GetValue()" function should return a void pointer if you want it
to work for all types. Of course, to use it for anything, you would
have to cast it to the appropriate type, so it is of limited use IMHO.
At the very least, you need to hide such details from clients by
implementing conversion functions -- or else proide a complete set of
"Get...()" functions (e.g.GetInt(), GetDouble(), etc.) -- or return a
proxy object from operator[], for example, which handles the
conversions transparently.
Not a trivial undertaking, and it's still going to be messy at best.
--
Bob Hairgrove
No**********@Home.com