flâneur — a map of the web's best reading

CS111 assign5 C++ Guide

web.stanford.edu · 874 words · saved by 1 readers

We have used classes on the prior assignments - they are a way to define a new variable type. Check out our C/C++ guide for some resources on classes in C++. Note that most of the methods of the Thread class are declared as static; this means that the methods are associated with the Thread class rather than a specific Thread object. For a normal method, such as schedule, you invoke it using an instance of the class, like this: A static method is declared with the keyword static. For example, here is the declaration of current in thread.hh: You invoke it using the class, like this: When a normal method is executing, a pointer to the current object is available as the variable this, and you can access instance variables in that object directly. When a static method executes, there is no current object and no this variable available to the code of the method. A static method can't reference instance variables of the "current object" because there is no "current object". Static methods are

CS111 assign5 C++ Guide assign5 C++ Guide --> Written by John Ousterhout and Nick Troccoli Classes We have used classes on the prior assignments - they are a way to define a new variable type. Check out our C/C++ guide for some resources on classes in C++. Static Methods Note that most of the methods of the Thread class are declared as static ; this means that the methods are associated with the Thread class rather than a specific Thread object. For a normal method, such as schedule , you invoke it using an instance of the class, like this: Thread *thread = new Thread(myFunc); ... thread->sche

Explore this link on the map →

related reading