Re: Virtual Functions And Inline Definition
* Neelesh:
On May 8, 3:12 pm, "Alf P. Steinbach" <al...@start.no> wrote:
* Neelesh:
On May 8, 1:59 pm, James Kanze <james.ka...@gmail.com> wrote:
On May 7, 9:04 pm, Neelesh <neelesh.bo...@gmail.com> wrote:
On May 7, 11:36 pm, Marcelo De Brito <Nosopho...@gmail.com> wrote:
Why is not possible to define a pure virtual inline function
in C++?
It is possible (but the 'inline' request will be ignored).
It certainly will not be ignored.
The above inline request can be honored by the compiler only if the
compiler can prove that this function is never called polymorphically.
I guess that is extremely difficult.
I'm sorry, the above is meaningless.
It seems that you have misunderstood what 'inline' is about.
It has a guaranteed effect and a hinting effect; read up on it.
Is "hinting effect" a technical term? I'm sorry I'm not aware of it.
Did a quick googling but that couldn't help. Also, this term doesn't
seem appear in the C++ standard
My _only_ understanding about semantics of "inline" specifier is this:
-It is a request made to the compiler and the compiler is at its own
descretion whether to obey this request or not. Of course, it will
obey if it can.
- If there are any specific cases where the compiler is "forced" to
inline, then I am not aware of such cases.
- I gather that if a function is inlined, _all_ its calls must be
substituted by its definition. I am not aware if the compilers are
allowed to selectively replace the calls that it can.
Would be greatful if you could point to a relevant resource that talks
about all these, specially the "hinting effect".
What you describe is the hinting effect.
The guaranteed effect is to allow multiple in-a-practical-sense-identical
definitions as long as they're in different compilation units, which as a matter
of in-practice programming allows you to define routines in header files.
The guaranteed effect is the only effect that you should be concerned about
(hinting is only for effeminate politicians, not for engineers), i.e., just
forget that hinting stuff -- although before forgetting it, note that contrary
to your description machine code inlining is decided per call, not per routine.
Cheers & hth.,
- Alf
--
Due to hosting requirements I need visits to <url: http://alfps.izfree.com/>.
No ads, and there is some C++ stuff! :-) Just going there is good. Linking
to it is even better! Thanks in advance!