Re: Interfaces in C++
On 2008-10-07 02:07:33 -0400, anon <anon@no.invalid> said:
Maik wrote:
On 6 Okt., 21:12, "A.Gallus" <u...@rz.uni-karlsruhe.de> wrote:
Bingo, that did the job, thx!
class A
{
virtual void myfunc() = 0;
};
class B : public A
{
You should consider to prefer
class B : public virtual A
to avoid being bitten by:
http://www.parashift.com/c++-faq-lite/multiple-inheritance.html#faq-25.8
which will most likely happen if one uses the interface pattern.
I think that is worse performance wise then just this:
class B : public A
At least thats what I read here:
http://www.agner.org/optimize/#optimize
And int is faster than double, so I won't use floating-point.
Unfortunately, that often gives the wrong answer.
Seriously: virtual and non-virtual inheritance have rather different
meanings, and performance concerns (whether real or imaginary) never
overrule correct semantics.
--
Pete
Roundhouse Consulting, Ltd. (www.versatilecoding.com) Author of "The
Standard C++ Library Extensions: a Tutorial and Reference
(www.petebecker.com/tr1book)