position of virtual keyword in function declaration

后端 未结 4 920
南方客
南方客 2021-01-21 01:55

Does it make any difference whether I place the virtual keyword in a function declaration before or after the return value type?

virtual void DoSome         


        
4条回答
  •  [愿得一人]
    2021-01-21 02:15

    Both the formats work but the standard specifys the first format.

    Reference:
    C++03 7.1 Specifiers

    The specifiers that can be used in a declaration are

       decl-specifier:
             storage-class-specifier
             type-specifier
             function-specifier
             friend
             typedef
    
         decl-specifier-seq:
               decl-specifier-seqopt decl-specifier
    

    And further function-specifier are explained in,

    7.1.2 Function specifiers

    Function-specifiers can be used only in function declarations.

     function-specifier:
         inline
         virtual
         explicit
    

提交回复
热议问题