Thursday 14 May 2015

What are the differences between a declaration and a definition?

There are two differences between a declaration and a definition:

  1. In the definition of a variable space is reserved for the variable and some initial value is given to it, whereas a declaration identifies the type of the variable.
  2. Redefinition is an error, whereas, redeclaration is not an error.
Example of Definition:
int a=10;
char  ch='A';

Example of Declaration:
extern int a;
extern char ch;

No comments:

Post a Comment