Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't call the method from the derived class when using references/pointers #3313

Open
cpocol opened this issue May 8, 2024 · 0 comments
Open

Comments

@cpocol
Copy link

cpocol commented May 8, 2024

I'm having these two objects:

TFT_eSPI display = TFT_eSPI();
TFT_eSprite sprite = TFT_eSprite(&display);

As TFT_eSprite is derived from TFT_eSPI, I expect to easily switch between the two,

by using either

TFT_eSPI* pDisplay = &display;

or

TFT_eSPI* pDisplay = &sprite;

But calling this:

pDisplay->pushImage(x, y, w, h, data);

will always use the pushImage method from the base class.

pushImage and other methods that are inherited from the base class should be virtual in the base class.

Am I missing something? Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant