Re: Creating thread from a class object

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance




"Ben Voigt" <rbv@xxxxxxxxxxxxx> wrote in message
news:eikK2mONHHA.3944@xxxxxxxxxxxxxxxxxxxxxxx
Not at all. Any class member function, whether static or not, has full
privilege to access private members, including static member functions and
data, and non-static member functions and data of any instance of the
class. The fact that non-static functions always know of at least one
instance (the this pointer) and static functions does not decrease the
ability of static functions to reach inside arguments, globals, and so
forth having that type and use all the private members.

While you might be able to implement stream insertion operators (ie cout
<< o) using only the public interface, the fact is that static member
functions can use the private interface as well.

Ben,

Thanks for your reply. :-)
I meant exactly what you are saying here.
If a static function receives a pointer to an instance of its own class, it
has access to its private members though that pointer.
And that IS an advantage when using a static member function as a thread
proc.

Rgrds,

Rob.




.



Relevant Pages

  • Re: EnumChildWindows and C++
    ... I have a good stack of reading material now. ... Generally a *public* static member function can be used ... > whereever a C-style non-member function can be used. ...
    (microsoft.public.win32.programmer.ui)
  • Re: Microsoft Data Access Block and static methods
    ... "If User A calls my web service at the same time User B calls it, ... "I would figure it to be completely opposite - that if multiple threads ... returned to the wrong user, whereas in an instance member, each method ... not, I am), before writing or accessing a static member. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Whats wrong withthe code?
    ... Rob Williscroft wrote: ... >>Can you really have a static member that is the same type as the class ... but seems strange to me. ...
    (comp.lang.cpp)
  • Re: Methods and Threading
    ... My backgroundCalc function needs to access several private members such ... as GPIBDevice1, 2, and the a static text member in the form (all of ... Therefore, using a static member ...
    (microsoft.public.vc.mfc)
  • Re: a small question about object-orientation
    ... > Let's say I have a class Car, and this class has some private members ... Any functions that is not a member of a car ... > compiler which controls this access control or what? ...
    (comp.lang.java.programmer)