How do I do to call a specific method present on all classes from an other (TranslationManager) class ? I simplified a lot the code. I just want to call the setTranslationText
of any class from TranslationManager.
These are to take in consideration:
- All classes have a
setTranslationText
method -
We should call setTranslationText of any class from TranslationManager by using the pointer to the class
class Interface { ... public: void setTranslationText(QString translatedString); } class AnyOtherInterface { ... public: void setTranslationText(QString translatedString); } ... … Translationmanager::Translationmanager(){ AnyClass = Interface; // Pointer to Interface Class AnyClass->setTranslatioNText("Text"); AnyClass = AnyOtherInterface; // Pointer to AnyOtherInterface Class AnyClass->setTranslatioNText("AnotherText"); } …
Aucun commentaire:
Enregistrer un commentaire