By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,655 Members | 962 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,655 IT Pros & Developers. It's quick & easy.

again inline

P: n/a
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?

Jul 23 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
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
Jul 23 '05 #2

P: n/a
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.

Jul 23 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.