jeudi 20 octobre 2016

C++, pattern to initialize classes

In my code I'm implementing so many different classes that need to be initialized once the program's process is activated.

I am currently initiating manually each class, but they are so many, I thought that I could inherit from some class and each object created would be saved in a vector and could initalize the class from the object (base class) created, but I only need to initalize the class once, and even though I can set a flag for that, I dont think is a good solution.

Other solution that I thought is implement a kind of initializer on each class (static variable) that I have to initalize, same implementation, save the init object per class in a vector, and then init all the classes from the initializer class, but I have to pass to that object a lot of parametres and even functions. so is a good solution but a bad implementing, think so.

so Do you know for some good pattern to initialize classes?

Aucun commentaire:

Enregistrer un commentaire