When defining a function with an empty body, how is it more correct to write its code and does the “logic” of the function itself depend on it?
If there is no difference, is there a difference in performance, code readability, etc.?

foo(){} 

or

 foo(){;} 

And, if not difficult, explain in detail.

  • No difference .... - Harry
  • one
    {} cleaner and less visually "noisy." In the compiled form there is no difference. - Lyth
  • one
    Empty body - approx. Why add another empty instruction? Absolutely no reason. Use the first option. - Jenssen
  • one
    can a signor ask? It is quite possible that before that he was programming in some kind of cunning dialect with ++, where this semicolon mattered or he had a mentor who fingered for the lack of this semicolon. - KoVadim
  • four
    I figured out why this might be necessary - the person clearly marks the functions, for example, to show that it is already written completely (or vice versa, it requires writing). - KoVadim

1 answer 1

There is absolutely no difference, it is just easier to read in the first case. The second option is not only that it does not look very good, it also contains garbage in the form of empty instructions.