WHAT IS THE DIFFERENCE BETWEEN DECLARATION AND DEFINITION?

Ankit Singh

Total Post:15

Points:75
Posted by  Ankit Singh
C# 
 667  View(s)
Ratings:
Rate this:
  1. Ankit Singh

    Post:15

    Points:75
    What is the difference between declaration and definition?



    Difference between declaration and definition


    A declaration introduces an identifier and describes its type, be it a type, object, or function. A declaration is what the compiler needs to accept references to that identifier.

    A definition actually instantiates/implements this identifier. It's what the linker needs in order to link references to those entities. 

    The declaration tells the compiler that at some later point we plan to present the definition of this declaration.

    E.g.: void stars () //function declaration
    The definition contains the actual implementation.
    E.g.: void stars () // declarator
    {
    for(int j=10; j > =0; j--) //function body
    cout << *;
    cout << endl; }

      Modified On Mar-28-2016 04:12:15 AM

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!