Difference between Definition and Declaration

SHARE

Definition

  • Definition, with respect to a function indicates that the body of the function has been developed.
  • With respect to variable, it means a value has been associated/defined with that variable.
  • A function can be defined only once.
  • Once a function or variable has been defined, it is ready to be used.
  • A variable can be re-defined multiple times, as and when required. This depends on the language and the scopes.
  • Memory is allocated when function or a variable is defined.

Declaration

  • Function declaration basically means that a name has been given and the parameters have been mentioned.
  • No value is associated with a variable when it is just declared.
  • Its body hasn’t been developed yet.
  • Once a function or variable has been declared, it is not yet ready to be used.
  • A function or variable can be declared any number of times.
  • Memory isn’t allocated when a function or variable is declared.