Jump to content

Virtual operator++ in base class never getting called?

Recommended Posts

My classes are like this:

class Object
virtual operator++();

class Asset : public Object


When I use the ++ operator on a pointer to an object of the class Asset, the function never gets called:

Asset* asset = new Asset;



Share this post

Link to post

Makes sense. As a pointer holds a physical address in memory using the ++ operator sounds like it would just increment the position in memory or do nothing... one of the two.


The overloaded ++ operator you defined in the class is defined for an object and not a pointer to an object. Sounds right to me


(*asset)++ is what you want but I'm sure you know that already by now

Share this post

Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...