Using the this Pointer

We have seen that an object's member functions can manipulate the object's data. How do member functions know which object's data members to manipulate? Every object has access to its own address through a pointer called this (a C++ keyword).

Figure 2.18: this pointer implicitly and explicitly used to access an object's members. (part 1 of 2)
\includegraphics[scale=0.45]{figures//img7.40.ps}
\includegraphics[scale=0.45]{figures//img7.41.ps}
Figure 2.19: this pointer implicitly and explicitly used to access an object's members. (part 2 of 2)
\includegraphics[scale=0.45]{figures//img7.42.ps}
Figure 2.20: Time class definition modified to enable cascaded member-function calls.
\includegraphics[scale=0.45]{figures//img7.44.ps}
\includegraphics[scale=0.45]{figures//img7.45.ps}
Figure 2.21: Time class member-function definitions modified to enable cascaded member-function calls. (part 1 of 3)
\includegraphics[scale=0.45]{figures//img7.46.ps}
\includegraphics[scale=0.45]{figures//img7.47.ps}
Figure 2.22: Time class member-function definitions modified to enable cascaded member-function calls. (part 2 of 3)
\includegraphics[scale=0.45]{figures//img7.48.ps}
\includegraphics[scale=0.45]{figures//img7.49.ps}
Figure 2.23: Time class member-function definitions modified to enable cascaded member-function calls. (part 3 of 3)
\includegraphics[scale=0.45]{figures//img7.50.ps}
Figure 2.24: Cascading member-function calls.
\includegraphics[scale=0.45]{figures//img7.51.ps}
\includegraphics[scale=0.45]{figures//img7.52.ps}
2004-07-29