Is it possible to execute a function from a class that may vary?

Hi! I just started coding in C++ as of recently.

I have some objects, like CPP_Cup or CPP_CoffeeJug, that are interactable by the character. These classes will always have an unique “Interact” function depending on what it is interacting with (it may be able to pour into other objects or place onto a table). I want the character to be able to use these interact methods from within my CPP_BaseCharacter file. So far I’ve tried using the FindFunction but don’t know if this is the right way to do it.

Is such a thing even possible? Thanks in advance.

Sure… you can use polymorphism. You can use inheritance. (Interfaces or virtual classes)

1 Like

yeah I think inheritance is my best bet here. thanks for the feedback :slight_smile:

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.