Topic: Converting member functions to functions


Author: chris@toshiba.tic.oz.au (Chris Perrott)
Date: 2 May 94 23:31:35 GMT
Raw View
In <pjl.766584752@graceland.att.com> pjl@graceland.att.com (Paul J. Lucas) writes:

>In <2ope24$g4m@agate.berkeley.edu> umminger@beirut.berkeley.edu (Frederick W. Umminger) writes:

>>In article <pjl.766498753@graceland.att.com>,
>>Paul J. Lucas <pjl@graceland.att.com> again displays his
>>difficulties understanding the English language :
>>>
>>>>If you had _read_ my post, I was asking about converting a pointer to a
>>>>void Foo::bar() to a void (*)(Foo *const), not to a void (*)(void). The
>>>>Foo *const provides the object, it becomes the "this" pointer.
>>>
>>> I did _read_ your post.  The face that you've changed the

>>in my first post I acknowledged that, to the best of my knowledge,
>>this was illegal syntax.  The questions was _why_ _should_ it be illegal.
>>Why was Bjarne right to disallow it?

I feel that pointer to member causes great confusion because its name is
misleading.

class C
{
  int n;
  void f()
  {
    int* p1 = &n;           // p1 points to a member (of this instance).
    int C::*p2 = &C::n;     // p2 is called a 'pointer to member'.

If p2 above were called a 'relative pointer to member' or an 'object-relative
pointer' then I, for one, would find it much less confusing.

In section 8.1.2c of the ARM it says "This implies that pointers to members
are implemented as structures holding relative positions ....
The simplest implementation of a pointer to a nonstatic data member is simply
the offset of the member ....".