Topic: using and operators


Author: Gerard Weatherby <gerardw@alum.mit.edu>
Date: 1997/03/04
Raw View
Is it legitimate to use the "using" keyword in base class access control
mode with an operator? i.e. Something like:

class my_other_class;
class my_stream : public ostream {
  public:
     using ostream::operator<<;
     my_stream &operator<<(my_other_class &);
};
---
[ comp.std.c++ is moderated.  To submit articles: Try just posting with your
                newsreader.  If that fails, use mailto:std-c++@ncar.ucar.edu
  comp.std.c++ FAQ: http://reality.sgi.com/austern/std-c++/faq.html
  Moderation policy: http://reality.sgi.com/austern/std-c++/policy.html
  Comments? mailto:std-c++-request@ncar.ucar.edu
]





Author: fjh@mundook.cs.mu.OZ.AU (Fergus Henderson)
Date: 1997/03/05
Raw View
Gerard Weatherby <gerardw@alum.mit.edu> writes:

>Is it legitimate to use the "using" keyword in base class access control
>mode with an operator? i.e. Something like:
>
>class my_other_class;
>class my_stream : public ostream {
>  public:
>     using ostream::operator<<;
>     my_stream &operator<<(my_other_class &);
>};

I have no idea what "base class access control mode" is, but yes, the
above code is legitimate.  Pedantically speaking, you need to add

 #include <iostream>
 using std;

at the top to make it a well-formed program.

(It is not good design, IMHO, but that is a topic for a different newsgroup.)

--
Fergus Henderson <fjh@cs.mu.oz.au>   |  "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh>   |  of excellence is a lethal habit"
PGP: finger fjh@128.250.37.3         |     -- the last words of T. S. Garp.
---
[ comp.std.c++ is moderated.  To submit articles: Try just posting with your
                newsreader.  If that fails, use mailto:std-c++@ncar.ucar.edu
  comp.std.c++ FAQ: http://reality.sgi.com/austern/std-c++/faq.html
  Moderation policy: http://reality.sgi.com/austern/std-c++/policy.html
  Comments? mailto:std-c++-request@ncar.ucar.edu
]