Declaration and definition in C++

Discussion in 'C++' started by hkp819, Jan 7, 2009.

  1. hkp819

    hkp819 New Member

    Joined:
    Dec 4, 2008
    Messages:
    59
    Likes Received:
    1
    Trophy Points:
    0
    A declaration introduces a name into the program; a definition provides a unique description of an entity (e.g. type, instance, and function). Declarations can be repeated in a given scope, it introduces a name in a given scope. There must be exactly one definition of every object, function or class used in a C++ program.
    A declaration is a definition unless:

    * it declares a function without specifying its body,
    * it contains an extern specifier and no initializer or function body,
    * it is the declaration of a static class data member without a class definition,
    * it is a class name definition,
    * it is a typedef declaration.


    A definition is a declaration unless:

    * it defines a static class data member,
    * it defines a non-inline member function.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice