// ----------------------------------------------------------------------
//
// 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/<ISOcxxSyntax.hh>/"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<T>

#if ! defined DEFECT_ABSTRACT_VIRTUAL_BASE
template< class T >
int  D<T>::v()  {  return 0;  }
#endif


// ----------------------------------------------------------------------
// non-abstract class inheriting from both:
// ----------------------------------------------------------------------

template< class T >
struct D2 : public D<T>, virtual public B  {

  D2<T>  f();

#if defined DEFECT_ABSTRACT_VIRTUAL_BASE
  virtual  int  v();
#endif

};  // D2<T>

#if defined DEFECT_ABSTRACT_VIRTUAL_BASE
template< class T >
int  D2<T>::v()  {  return 0;  }
#endif


// ----------------------------------------------------------------------
// driver:
// ----------------------------------------------------------------------

int  main()  {

  D2<int>  d2i;
  return  d2i.v();

}  // main()
