[Ace-users] [tao-users] Use multiple inheritance failed

Matthew Gillen mgillen at bbn.com
Sun Oct 14 09:53:50 CDT 2007


Roland,
Your problem is that you're inheriting from two different POA_ classes, and
the compiler can't figure out which of implementation of ::is_a() (and a
couple other functions) should be used in your task_base_d class: the one
defined by POA_task or the one from POA_taskd.

Two ways you can deal with this:
- override all the functions you get "ambiguous inheritance" messages about
in your task_base_d class.
- don't inherit from two POA_ classes.  Instead, consider making task_base_i
a member of task_base_d

The second option is simpler since you don't have to know what the correct
semantics for ::is_a() should be for a multiple POA_ class.  However, you
lose some of the nice features of inheritance for your implementation classes.

The way I've solved this in the past is to have two "parallel" inheritance
hierarchies.  You keep your servant implementation classes (ie the ones that
inherit from POA_*) as small as possible (and only use single inheritance).
 Then you define the classes you want to have the inheritance relationship
by having them have member variables of the POA_-derived servant
implementation classes.

Hope that made sense,
Matt

rolandsun sun wrote:
> for simplify the problem ,I define the idl like following:
> /*****/
> interface task{
>         void a();
> };
> interface taskd{
>         void b();
> };
> /******/
> 
> in the main.cpp i define the class like this
> /*************************************************/
> 
> #include"taskS.h"
> class task_base_i :public virtual  POA_task {
>         public:
>   task_base_i(){};
>   virtual ~task_base_i(){};
>   virtual void a ( void)
>     ACE_THROW_SPEC ((
>       ::CORBA::SystemException
>     )) {}
> };
> 
> class task_base_d :public virtual task_base_i,public virtual POA_taskd{
>         public:
>   virtual
>   void a (
>       void
>     )
>     ACE_THROW_SPEC ((
>       ::CORBA::SystemException
>     )) {}
>   virtual
>   void b (
>       void
>     )
>     ACE_THROW_SPEC ((
>       ::CORBA::SystemException
>     )) {}
> };
> /*************************************************/
> 
> I still get the same errors.
> 
> so where is the problem?
> 
> On 10/12/07, *Steve Totten* <totten_s at ociweb.com
> <mailto:totten_s at ociweb.com>> wrote:
> 
>     Hello Roland,
> 
>     roland wrote:
>     >   ACE VERSION: 5.5.6
>     >
>     >     HOST MACHINE and OPERATING SYSTEM:
>     >  WINDOWS XP SP2  VSS2005
> 
>     Thanks for using the PRF!
> 
>     > I design the class like the example in the "Advanced CORBA Programming
>     > with C++ "
>     >   class Thermostat_impl :
>     >     public virtual POA_CCS::Thermostat,
>     >     public virtual Thermometer_impl {
>     > };
>     >
>     >  but the compiler report  error  :
>     >
>     > 1>d:\works\src\taskdistribproduct\TaskDistributProducts.h(93) : error
>     > C2250: 'ProductsDsitributor' : ambiguous inheritance of
>     'CORBA::Boolean
>     > TAO_Abstract_ServantBase::_is_a(const char *)'
>     > 1>d:\works\src\taskdistribproduct\TaskDistributProducts.h(93) : error
>     > C2250: 'ProductsDsitributor' : ambiguous inheritance of 'void
>     > TAO_Abstract_ServantBase::_dispatch(TAO_ServerRequest &,void *)'
>     > 1>d:\works\src\taskdistribproduct\TaskDistributProducts.h(93) : error
>     > C2250: 'ProductsDsitributor' : ambiguous inheritance of 'const char
>     > *TAO_Abstract_ServantBase::_interface_repository_id(void) const'
>     > 1
> 
>     How have you defined class Thermometer_impl?  Be sure it also
>     uses *virtual* inheritance from its base (skeleton) class
>     POA_CCS::Thermometer, as shown in "Advanced CORBA Programming
>     with C++", section 11.6.1.
> 
>     By the way, OCI's "CORBA Programming with C++" training course
>     covers topics such as this in detail.
> 
>     http://www.ociweb.com/education/services/descrip/ESDC02-01.html
> 
>     If you are interested, please contact me directly or contact our
>     training department at training at ociweb.com <mailto:training at ociweb.com>.
> 
>     Steve
>     --
>     ----------------------------------------------------------------
>     Steve Totten, Principal Software Engineer and Partner
>     Object Computing, Inc. (OCI), St. Louis, MO, USA
>     http://www.ociweb.com/  http://www.theaceorb.com/
>     ----------------------------------------------------------------
> 
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> tao-users mailing list
> tao-users at mail.cse.wustl.edu
> http://mail.cse.wustl.edu/mailman/listinfo/tao-users



More information about the Ace-users mailing list