Archived

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

NogginBoink

Explain this mistake to me

Recommended Posts

In my code, I accidentally had: MyObject->Render; instead of MyObject->Render(); The complier didn''t complain when I omitted the parentheses, but my function wasn''t called. I can''t for the life of me figure out what I was telling the compiler to do by accident. Can anyone explain?

Share this post


Link to post
Share on other sites
It''s evaluating the MyObject->Render to be the address of Render in the MyObject object. It''s the same convention that allows you to create function pointers.

It''s the same as going:

int iSomething = 0;
iSomething

It''ll be ignored by an optimising compiler, hopefully anyway!

Share this post


Link to post
Share on other sites
You should find a better compiler that will warn you about that. It''s certainly legal (it creates a function pointer and then throws it away) and will probably be optimized out to nothing, but it sucks not to find out that you screwed up until runtime...

Share this post


Link to post
Share on other sites