dimanche 15 décembre 2019

Design techniques for avoiding the need of virtual functions [closed]

I want to have an EffectManager(I know that's a bad name) that creates, stores, updates and renders different kinds of effects. In my OOP design I have a class EffectManager that stores pointers to the Effect base class from which all other effects inherit. Effect has a virtualupdate and draw method which the derived classes implement. But I am currently converting my C++ code to C code and going from OOP to procedural. I know I can imitate this virtual method behavior with function pointers but I read that this is error prone and that it is better to avoid it. How would one implement this if the virtual function behavior should be avoided? What other design techniques are there to solve this problem?

Best regards

Aucun commentaire:

Enregistrer un commentaire