Thursday, 8 November 2012

difference between delarations and definitions

A declaration provides basic attributes of a symbol: its type and its name. 
A definition provides all of the details of that symbol--if it's a function, what it does; if it's a class, what fields and methods it has; if it's a variable, where that variable is stored. 
Often, the compiler only needs to have a declaration for something in order to compile a file into an object file, expecting that the linker can find the definition from another file.
 If no source file ever defines a symbol, but it is declared, you will get errors at link time complaining about undefined symbols.

 

No comments:

Post a Comment