Topic: Pointer2Member initialization with 0


Author: Frank Uepping <Frank.Uepping@epost.de>
Date: Sat, 24 Nov 2001 01:54:56 GMT
Raw View
class X
{
public:
  X ()
  {
    pm = 0;  // Is the initialization of a pointer to member with
             // zero permitted by the standard?
  }

  void x ()
  {
    if (pm != 0)  // Compatible/Permitted?
      (this->*pm) ();
  }

private:
  typedef void (*f) ();
  f X::*pm;
};


Thanks
    FAU


---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.research.att.com/~austern/csc/faq.html                ]





Author: "James Kuyper Jr." <kuyper@wizard.net>
Date: Sat, 24 Nov 2001 04:20:32 GMT
Raw View
Frank Uepping wrote:
>
> class X
> {
> public:
>   X ()
>   {
>     pm = 0;  // Is the initialization of a pointer to member with
>              // zero permitted by the standard?

Yes - see 4.11p1.

>   }
>
>   void x ()
>   {
>     if (pm != 0)  // Compatible/Permitted?

Yes - see 5.10p2

>       (this->*pm) ();
>   }
>
> private:
>   typedef void (*f) ();
>   f X::*pm;
> };

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.research.att.com/~austern/csc/faq.html                ]