I want to implement some object container like java bean does,for example:
I have several objects like pig,apple,dog....which may be constructed and used in my framewrok.

```
class pig:public object{
     public:
        pig(double weight);
};
class apple:public object{
     public:
        apple(int qty);
};
class dog:public object{
     public:
        dog(int qty);
};
#define kPIG 1
#define kApple 2
#define kDog  3
...
object *o1 = factory::create(kPig,100.0);
object *o2 = factory::create(kApple,2);
object *o3 = factory::create(kDog,3);
...

for those factory::creates:
1. return same type:pointer of base
2. first arg indicates the object type and followed by variable args accordingly.

```

of course I could using a factory pattern or simply 'switch-case' to create it. the key point is when the framework is published and other user adds a new object to expand the scope in binary, the framework should has ablity to recognize the new object like kPear(100) and constuct it corectly.

```
class pear:public object{
   public:
      pear(int,double,string);
}
const kPear = factory::register(pear);

object *pear =  factory::create(kPear,200,10.0,"good");

```

how can i implemente this gracefully. any sugguest or examples will be appreciated.
c++ template will be ok.