Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

Why threads are declared as static when used from a class?

class declared static threads Used
0
Posted

Why threads are declared as static when used from a class?

0

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

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.

Experts123