On 2008-08-27 15:28:42 -0400, sunil <sunilsreenivas2001@yahoo.comsaid:
Quote:
>
what I mean by orthogonal is that they dont make sense together for
inlines code get replaced at compile time for virtual the call happens
at runtime thru virtual table, so if you define a virutal function as
inline and you try to call it thru base pointer it wont work since
compiler wouldnt know what function to call (since its inlined, the
function wont exist in compiled code)
But it will. The compiler has to do the right thing. It can generate
the code inline when it's appropriate, and it must provide a definition
for use in a virtual call.
struct Base
{
inline virtual void f();
};
struct Derived : Base
{
inline virtual void f() { ... }
};
void g(Base& bb)
{
Base b;
b.f(); // calls B::f; can be inlined
Derived d;
d.f(); // Calls D::f; can be inlined
bb.f(); // Don't know what it calls; can't be inlined
}
--
Pete
Roundhouse Consulting, Ltd. (
www.versatilecoding.com) Author of "The
Standard C++ Library Extensions: a Tutorial and Reference
(
www.petebecker.com/tr1book)