Topic: Question about overloading
Author: maxtal@physics.su.OZ.AU (John Max Skaller)
  Date: Thu, 11 Aug 1994 11:22:14 GMT Raw View
In article <31ti6g$65i@agate.berkeley.edu> dougal@homer.CS.Berkeley.EDU (Doug Hauge) writes:
>
>   Should the following overloading be allowed?
>
>class A {
>   static void f();
>   void f() const;
>};
 Dont know but a _call_ to f() is not allowed here.
Its not allowed in the case:
 class A {
  static void f();
  void f(int);
 };
either: name binding and selection of candidates for
overload resolution is done first and result must not
be a set containing both static and non-static functions.
(San Diego resolution)
--
        JOHN (MAX) SKALLER,         INTERNET:maxtal@suphys.physics.su.oz.au
 Maxtal Pty Ltd,
        81A Glebe Point Rd, GLEBE   Mem: SA IT/9/22,SC22/WG21
        NSW 2037, AUSTRALIA     Phone: 61-2-566-2189
Author: dougal@homer.CS.Berkeley.EDU (Doug Hauge)
  Date: 5 Aug 1994 14:26:24 GMT Raw View
   Should the following overloading be allowed?
class A {
   static void f();
   void f() const;
};
   ARM 9.4 states that "there cannot be a static and a nonstatic
member function with the same name and the same argument types",
but "argument types" includes the implicit `this' parameter in
the following case: (Here, I am going by the use of "argument types"
                     in the rules in ARM 13)
   class A {
      void f();
      void f() const;   // allowed because differ enough in type of this
   };
but not in:
   class A {
      void f();
      static void f();   // error because { A a;  a.f(); } is ambiguous
   };
   I would think that the latter case should apply to the above
example, and it should be an error.  However, g++ allows it and
disambiguates based on the object on which the method was invoked
(upon the type of `this' in method definitions).
(However, ARM 13 "Member functions that differ only in that one is a
static member and the other isn't may not have the same name (9.4)"
would seem by omission to support g++'s interpretation, but this
would also allow
   class A {
      void f(int);
      static void f(int&);
   };
which shouldn't be allowed, should it?)
Doug
--
dougal@cs.berkeley.edu