Re: create an object with variable CLASS

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Mohsen Pahlevanzadeh wrote:
> Dear Axel,
> I said my means badly,Suppose I have following code:
> module_management::load_module(char *class_name){
> }/////////////////////
> I wanna create an object for each class that it is argument of my
> function.
> same: 
> class_name *my_obj = new class_name;
> I can't implement it.

Why not?  Make sure that every class has a common superclass and a
static initializer that registers a constructor with a registry.
Then, when you want an instance of class X, call
theRegistry.newClass("X").  theRegistry looks up "X" and creates an
instance of X.  theRegistry is just a few lines of C++: it's a map
from string -> constructor.

Andrew.

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux