Jump to content
  • Advertisement
Sign in to follow this  
sheep19

What's the difference between virtual void something() and void virtual something()?

This topic is 3721 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 seen in my C++ book that the author sometimes uses:
void virtual sayHi() const;
or
virtual void sayHi() const;
What's the difference? (I've seen later that he used virtual void hi() const = 0; to make it pure virtual, could I use void virtual hi() const = 0; ?) If they are the same, which is used more often?

Share this post


Link to post
Share on other sites
Advertisement
They're the same, although the virtual keyword almost always comes before the return type. So virtual void foo(); is the usual form.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • 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!