mercredi 11 janvier 2017

Is it needed to avoid function parameters as non-pod structures?

So, the question is, should I avoid usage of non-POD structures (for example which contains std::string or smth else) while passing such objects to functions as parameters?

For instance, as well as I know, there are many initialization structures in WinAPI, but they are still POD. Is it a good style to use structures in that way? Or should I use some pattern to avoid this? Am I right that this is some kind of "poltergeist" anti-pattern?

Moreover I would like to pass strings and other containers via such structures. It means that this structures appears to be non-POD. For now I would say that I need nearly 20 such initialization-structures.

Is it better to create builder pattern instead? In this case it will be the same number of structures, right? In addition I have factories for some objects so for them I can avoid creating addition builder class.

What it is preffered way of solving problem of initialization?

Aucun commentaire:

Enregistrer un commentaire