Why threads are declared as static when used from a class?
A. Toby Opferman quoted :- Functions used to be created as threads are defined as “static” when used with a C++ class because there is an implied parameter that doesn’t show up in code, the THIS pointer. To avoid this confusion and make it simple, “static” class members only operate on static data and not per-instance data and as such the “this” pointer is not passed in. So, it’s easy to define the function as static and use it in CreateThread without worries. Of course, they usually pass the object instance as the first parameter anyway.
Related Questions
- Can enzymes used in dough conditioners in a bakery product be declared by a class name "enzymes" or must they be declared by the actual name of the enzymes in the Ingredient List?
- Would it be necessary for children to have used Numicon at the Foundation stage first, or could we start a group/class at the next level?
- Why threads are declared as static when used from a class?