// ---------------------------------------------------------------------- // // absvbase.cc - Test virtual inheritance from an abstract base class. // // History: // 06-Oct-1999 WEB Initial draft, adapted from Scott Snyder's example // 21-Oct-1999 WEB Add unnecessary D2<>::v() to compensate for defect // 25-Apr-2001 WEB s//"ISOcxx\/ISOcxxSyntax.hh"/ // // ---------------------------------------------------------------------- #include "ISOcxx/ISOcxxSyntax.hh" // ---------------------------------------------------------------------- // abstract class to serve as a base: // ---------------------------------------------------------------------- struct B { virtual int v() = 0; }; // B // ---------------------------------------------------------------------- // derived non-abstract class: // ---------------------------------------------------------------------- template< class T > struct D : virtual public B { #if ! defined DEFECT_ABSTRACT_VIRTUAL_BASE virtual int v(); #endif }; // D #if ! defined DEFECT_ABSTRACT_VIRTUAL_BASE template< class T > int D::v() { return 0; } #endif // ---------------------------------------------------------------------- // non-abstract class inheriting from both: // ---------------------------------------------------------------------- template< class T > struct D2 : public D, virtual public B { D2 f(); #if defined DEFECT_ABSTRACT_VIRTUAL_BASE virtual int v(); #endif }; // D2 #if defined DEFECT_ABSTRACT_VIRTUAL_BASE template< class T > int D2::v() { return 0; } #endif // ---------------------------------------------------------------------- // driver: // ---------------------------------------------------------------------- int main() { D2 d2i; return d2i.v(); } // main()