More virtual base class fun

Started by
3 comments, last by superpig 20 years, 6 months ago

class IBase
{
 virtual void A()=0;
 virtual void B()=0;
};

class C1 : virtual public IBase
{
 A() { txtOut("C1::A called"); }
 B() { doSomething(); A(); }
};

class IExtendedBase : virtual public IBase
{
 virtual void ExtraOperation()=0;
};

class CExtended1 : public C1, public IExtendedBase
{
 ExtraOperation(){ doSomethingElse(); }
 A() { txtOut("CE1::A called"); }
};

CExtended1 e;
e.B();
Is calling function B() on CExtended1 fully valid like that, and will it go on to call C1::A or CExtended1::A? I think it''ll call CExtended1::A, but I wanted to check. (I''m trying to extend an interface and its implementation, in case you were wondering why the hell I''d ever want to do this). Richard "Superpig" Fine - saving pigs from untimely fates, and when he''s not doing that, runs The Binary Refinery.
Enginuity1 | Enginuity2 | Enginuity3 | Enginuity4 ry. .ibu cy. .y''ybu. .abu ry. dy. "sy. .ubu py. .ebu ry. py. .ibu gy." fy. .ibu ny. .ebu OpenGL is a language

Richard "Superpig" Fine - saving pigs from untimely fates - Microsoft DirectX MVP 2006/2007/2008/2009
"Shaders are not meant to do everything. Of course you can try to use it for everything, but it's like playing football using cabbage." - MickeyMouse

Advertisement
IMO, haing a virtual abstract base type doesn''t make much sense
Yes, CExtended1::A.

quote:Original post by Anonymous Poster
IMO, haing a virtual abstract base type doesn''t make much sense

It makes perfect sense.

[ Google || Start Here || ACCU || STL || Boost || MSDN || GotW || CUJ || MSVC++ Library Fixes || BarrysWorld || E-Mail Me ]
[ Google || Start Here || ACCU || STL || Boost || MSDN || GotW || CUJ || MSVC++ Library Fixes || BarrysWorld || [email=lektrix@barrysworld.com]E-Mail Me[/email] ]
quote:Original post by Lektrix
It makes perfect sense.


I honestly don''t think it does either.

[ Start Here ! | How To Ask Smart Questions | Recommended C++ Books | C++ FAQ Lite | Function Ptrs | CppTips Archive ]
[ Header Files | File Format Docs | LNK2001 | C++ STL Doc | STLPort | Free C++ IDE | Boost C++ Lib | MSVC6 Lib Fixes ]
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan
virtual abstract base types are pretty much only useful for interfaces.
daerid@gmail.com

This topic is closed to new replies.

Advertisement