If a function is declared multiple times but defined only once, will the program compile successfully?

  • It depends on the compiler
  • It depends on the function name
  • No
  • Yes
Yes, if a function is declared multiple times but defined only once in a program, it will compile successfully. This is because function declarations inform the compiler about the function's signature and return type, allowing it to check for consistency when the function is called in different parts of the code. The definition provides the actual implementation.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *