#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2004
    Posts
    39
    Rep Power
    11

    C++ Terms... prototype, definition, implementation


    Hi All,

    I just had a quick question about the words "prototype" and "definition" in regards to C++ programming. Are they basically the same?

    I would say that:

    int plus(int a, int b);

    is a prototype. However can it also be called a definition or is the definition the actual implementation itself?

    Thanks for answering a noobs question....

    Jufafs
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    May 2004
    Location
    Adelaide, Australia
    Posts
    880
    Rep Power
    11
    I would say that

    Code:
    int plus(int a, int b);
    is the declaration whereas

    Code:
    int plus(int a, int b)
    {
      return a + b;
    }
    is the definition
  4. #3
  5. Left due to despotic ad-min
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Jun 2003
    Posts
    1,044
    Rep Power
    14
    In this case, the way Dark has used declaration and definition are consistent with their meaning (and definition) in the C and C++ standards.

    The actual definition of the terms is a bit more complex (as it has to cover declarations and definitions of functions, types, variables, etc etc).
    It is only our bad temper that we put down to being tired or worried or hungry; we put our good temper down to ourselves."
    -- C.S. Lewis

    I like long walks, especially when they're taken by people who annoy me.
    --Fred Allen

IMN logo majestic logo threadwatch logo seochat tools logo