Josh Posted November 16, 2012 Share Posted November 16, 2012 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? Quote 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 More sharing options...
Josh Posted November 16, 2012 Author Share Posted November 16, 2012 Hmmm, apparently you cannot use operator overloading with pointers. I did not know that: http://stackoverflow.com/questions/6171630/why-isnt-operator-overloading-for-pointers-allowed-to-work Quote 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 More sharing options...
Road Kill Kenny Posted November 16, 2012 Share Posted November 16, 2012 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 2 Quote 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 More sharing options...
Recommended Posts
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.