Topic: Overloading of inherited operations (Continued Discussion)


Author: Sergey Zhupanov <sergey@cis.ohio-state.edu>
Date: 1995/11/14
Raw View
First I would like to thank all the folks who kindly replied to my original
posting.  The newly introduced "using" directive does indeed solve the
problem for the case of the two simple examples I provided.

For example:

class P1 { public: void foo (int); };
class P2 { public: void foo (char); };
class C: public P1, public P2
{
public:
   using P1::foo;
   using P2::foo;
   void foo (double);
};

makes C export all three overloaded operations: foo(char), foo(int), and
foo(double).

The main reason this works is that here we know the number and the names of
the operations we are inheriting (and overloading.)  Consider, however, a
more general case, in which neither of these are known:

template <class Parent_1, class Parent_2>
class Child : public Parent_1, public Parent_2
{
public:
   // Desired: Interface of Child to be the UNION of
   //          interfaces of Parent_1 and Parent_2.
};

Is it possible to say anything in the public section of Child to make the
above "wish" be a reality?  In other words, is it possible to make the
interface of Child export the overloaded operations from Parents'
interfaces?  For example, can Child export both Parent_1::foo(int) and
Parent_2::foo(char) WITHOUT KNOWING their names or even the number of such
overloadings that would take place?

Thanks very much,
  sergey

sergey@cis.ohio-state.edu

Graduate Research Assistant,
Computer and Information Science Department,
The Ohio State University




---
[ comp.std.c++ is moderated.  Submission address: std-c++@ncar.ucar.edu.
  Contact address: std-c++-request@ncar.ucar.edu.  The moderation policy
  is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]