Topic: referring to static members in a member function
Author: pena@niksula.hut.fi (Olli-Matti Penttinen)
Date: 25 May 93 01:39:10 Raw View
What is the exact rule for referring to static members of a class?
Consider,
extern do_something(void (*)());
struct B {
static void f();
};
struct D : public B {
static void f();
g() { do_something(f); } // won't compile
};
The ARM seems to be a bit unclear in this situation. On the one hand,
it says (9.4):
"A static member mem of class cl can be referred to as cl::mem (5.1),
that is, independently of any object. It can also be referred to using
the . and -> member access operators (5.2.4)."
On the other hand, in section (10.4) the ARM says:
"A name that is not qualified in any of the ways described and that is
used in a function that is a nonstatic member of class X must [...],
be a member of class X or a base class of class X, [...] The
declaration of a member name hides declarations of the same name in
base classes and global names."
Seems to me that the code above should use D::f. In any case, the
meaning is quite clear and unambiguous, even if an ``extern void f()''
were introduced.
BTW. I have intentionally left to make and model of my compiler out of
this, since I'm primarily interested in the wording and not in whether
the compiler is broken or not. (FYI, It is broken :-)
Anyone?
==pena
--
Olli-Matti Penttinen <pena@niksula.cs.hut.fi>
Lehdesniityntie 3 F 91
00340 HELSINKI "When in doubt, use brute force."
tel. + 358 0 1399 0110 -- Ken Thompson