Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


Inheritance and Virtual Methods

This topic is 5770 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have an abstract class, Layer. It contains the following method stub. virtual void Draw(NPC player, int xlen, int ylen) = 0; I have (currently) two layers, an NPCLAYER and a TILELAYER that implement that method. These sub methods are not being called when I try and draw from the map. I have an array of layer pointers, and the layer pointers point to either a NPCLAYER or a TILELAYER. I''ve tried to call the inherited Draw method on the sub with the following line: mLayers->Draw(player, xlen, ylen); It compiles and links successfully, however, the program quits at that call, calling neither of it''s child methods.

Share this post

Link to post
Share on other sites
Thanks. Null pointer it was. I neglected to notice I was using impermanent data for testing.

As for the code, I know putting too much is confusing. And it''s a complex situation. But.. would have been helpful anyway.


Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!