May 2003
Intermediate to advanced
808 pages
32h 24m
English
this keyword — Object pointer in member function
primary-expr := thisThe this keyword can be used
only in nonstatic member functions. Its value is a pointer to the
target object of a member function call. If the member function is
qualified (with const or volatile), the same qualifiers apply to the
type of this.
struct point {
bool operator==(const point& that) {
returnthis->x() == that.x() && this->y() == that.y( );
}
bool operator!=(const point& that) {
return !(*this == that);
}
bool write(FILE* fp) {
fwrite(static_cast<void*>(this), sizeof(*this), 1, fp);
}
};class, expression, Chapter 6