Re: Is MSDN wrong? or I made a mistake? about static member function



On Mon, 10 Jul 2006 06:11:02 -0700, Fei Xu
<FeiXu@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote:

in http://msdn2.microsoft.com/en-us/library/480b7kf7.aspx, it says that
pGdiObject->DeleteTempMap(); // Causes compiler error
But I'm confused for a static member can be called by the object or a pointer.
Is there anything wrong of my understanding?

Static member functions can be called using that syntax, but the object
reference or pointer isn't evaluated. So for a static member function, the
following are equivalent:

p->f();
T::f();

The second one is much better style.

--
Doug Harrison
Visual C++ MVP
.



Relevant Pages

  • Re: Using a macro, can I change what type an object is being cast to?
    ... > class has a static member function that acts a dummy callback (called by the ... > pointer to a subclass) and uses that to call non-static member functions. ... > function before the subclass object has been constructed fully thus calling ...
    (comp.lang.cpp)
  • Re: P/Invoke MFC member
    ... Why not create a function which will make the call to the static member ... > exposes limited API functionality, ... > that returns a pointer to its CWinApp object. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: creating thread in C++
    ... This is defined behaviour as long as you always pass a non-NULL pointer ... to myclass together with the function pointer &myclass::threadstub to ... a static member function does not have ... required extern "C" linkage. ...
    (comp.programming.threads)
  • Re: Private constructor
    ... They can if they access it through a pointer or a reference. ... > With constructors, this is different although they are non-static. ... The static member can create an object of the ... Access control (which is the public/private/static protected rules). ...
    (comp.lang.cpp)
  • Re: Static/ non-static member access
    ... Static member functions certainly can use non-static members, ... have no "this" pointer and thus don't operate implicitly on an object ... // Placement new - constructs a T in the memory pointed to by temp. ...
    (microsoft.public.vc.language)