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

CS111 assign5 C++ Guide

web.stanford.edu · 963 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 NOTE: this website is out of date. This is the course web site from a past quarter. If you are a current student taking the course, you should visit the current class web site instead. If the current website is not yet visible by going to cs111.stanford.edu, it may be accessible by visiting this link until the new page is mounted at this address. Please be advised that courses' policies change with each new quarter and instructor, and any information on this out-of-date page may not apply to you. --> Written by John Ousterhout and Nick Troccoli Classes

Explore this link on the map →

related reading