Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.

Explain the difference between a function prototype and a function definition.?

question from to C++ how to program 8th edition.

Update:

chapter 3 page 99.

3 Answers

Relevance
  • ?
    Lv 7
    8 years ago
    Favorite Answer

    I don't have access to your book. Doesn't matter.

    A function prototype declares (note the use of DECLARE, not DEFINE) the function's name, return type, and the types and number of parameters (unless ... is used.) It does NOT create such a function. It simply declares it so that the compiler knows what to do with such a call.

    A function definition creates an instance of code that is the function, as well as declaring it. So a definition does both the work of declaration (prototyping) AND definition (function object creation.)

    A prototype may look like:

        int f( int a );

    while a definition may look like:

        int f( int a ) { return a; }

    The first example doesn't create the function. It simply declares some knowledge about it. The second example both declares knowledge about it AND creates it, as well.

    A definition is always also a declaration. But a declaration is not necessarily a definition.

  • Anonymous
    4 years ago

    Definition Of Prototype

  • ?
    Lv 4
    5 years ago

    Prototype Definition

Still have questions? Get your answers by asking now.