On Fri, 29 Aug 2003 20:07:01 +0300, White Wolf <wo***@freemail.hu> wrote:
Nico Massi wrote: Hi NG!
I have a class A that should store a vector of pointers to objects of
class B.
But class B contains a template argument and each of the stored
objects in class A could have a different template argument. So i
need a way to store an array of template objects in a non-template
class. Obviously this wont work
cause a can`t tell the compiler which template argument to use.
So whats the usual way to solve such a situation?
The first solution that comes to my mind is, create a non-template
base interface to class B and store pointers to that base interface
in A.
But i think this is not the best solution for that kind of problem.
IMHO you are trying to do some very suspicious desing. I suggest that
you
give us a higher level view of this problem (like: I want to handle
different complex numbers). Try stay away in that case from C++ terms
(if
it is feasible) and just try to define the problem. I guess there should
be
an easier solution.
ok here is what i will do:
i would be able to configure my app with a config file where i could set
some values
mostly there are simple values ( int, float, string would cover around 80% )
but i would also be able to read complex types like a 3D Vector or an RGB
color value
so i thought templates would be the way to go for the config values
for the config values i need a class that known all possible config values
by their name
the values would be saved in a config class where the app can query the
config for a value
by specifying its name