Sign in to follow this  
sheep19

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

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this