🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c++
Article #2584

RE: Overloading of inherited operations (Continued Discussion)

#2584
From: Sergey Zhupanov
Date: Tue, 14 Nov 1995 20:34
55 lines
2126 bytes
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. ]
Technical Details
Message-ID: <01BAB222.E9768200@slip3-24.acs.ohio-state.edu>
Path: arc1-ca.pugleaf.net!newsxfer.itd.umich.edu!agate!agate!Matt

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!newsxfer.itd.umich.edu!agate!agate!Matt
From: Sergey Zhupanov <sergey@cis.ohio-state.edu>
Newsgroups: comp.std.c++
Subject: RE: Overloading of inherited operations (Continued Discussion)
Date: 14 Nov 1995 20:34:11 GMT
Organization: <none>
Approved: Matt@Austern
Message-ID: <01BAB222.E9768200@slip3-24.acs.ohio-state.edu>
NNTP-Posting-Host: austern.hip.berkeley.edu