again inline

Discussion in 'C++' started by puzzlecracker, Feb 15, 2005.

  1. why do we need to define the inline function if it is included in (.h)
    - why can't its definition reside somewhere else, with (.h) having
    only its prototype?
     
    puzzlecracker, Feb 15, 2005
    #1
    1. Advertising

  2. puzzlecracker wrote:

    > why do we need to define the inline function if it is included in (.h)
    > - why can't its definition reside somewhere else, with (.h) having
    > only its prototype?



    The definition of an inline function must exist in any compilation unit
    (file) that it is used and not its declaration only, and these
    definitions of the function must all be the same.


    So the usual approach is to place its definition in a header file and
    #include it wherever we use that function.




    --
    Ioannis Vranos

    http://www23.brinkster.com/noicys
     
    Ioannis Vranos, Feb 15, 2005
    #2
    1. Advertising

  3. puzzlecracker wrote:

    > Why do we need to define the inline function if it is included in (.h)
    > Why can't its definition reside somewhere else
    > with (.h) having only its prototype?


    Probably just to simplify implementations.
    If you kept inline function definitions somewhere else --
    in a repository for example --
    you would need a way to tell your compiler
    where to look for the repository.

    This is a problem for function template definitions
    because the ANSI/ISO C++ does not (and probably can't)
    specify how function template definitions
    are archived and found.
     
    E. Robert Tisdale, Feb 15, 2005
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Abhi
    Replies:
    2
    Views:
    750
    E. Robert Tisdale
    Jul 3, 2003
  2. Alvin
    Replies:
    7
    Views:
    487
    E. Robert Tisdale
    May 6, 2005
  3. Replies:
    3
    Views:
    471
  4. Daniel Vallstrom
    Replies:
    2
    Views:
    1,941
    Kevin Bracey
    Nov 21, 2003
  5. Nish
    Replies:
    4
    Views:
    506
    Thomas Stegen
    Oct 8, 2004
Loading...

Share This Page