Jump to content

Virtual operator++ in base class never getting called?


Josh
 Share

Recommended Posts

My classes are like this:

class Object
{
public:
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;
asset++;

 

Why?

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

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

  • Upvote 2

STS - Scarlet Thread Studios

AKA: Engineer Ken

 

Fact: Game Development is hard... very bloody hard.. If you are not prepared to accept that.. Please give up now!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
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.

 Share

×
×
  • Create New...