Computer Science 1037A/B Lecture Notes - Lecture 4: Member Variable, Function Prototype, Operator Overloading

54 views6 pages

Document Summary

By default, the compiler provides each member function of a class with an implicit parameter that points to the object through which the member function is called, and this implicit parameter is called this". It is an implicit parameter passed to a member function, and points to the object calling the function. It can be used to access members that may be hidden by parameters with the same name. In this case, this" is used to point to the object member num. So it is used to make sure the compiler knows to use the class member object version of num. When const appears in the parameter list of a function, then that function is prevented from modifying the parameter, it is read-only: int setnum(const int num) When const follows the function, the function can"t modify the object: int getx() const.

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents

Related Questions