IAT 167 Lecture Notes - Lecture 4: Reference Type

83 views4 pages

Document Summary

Class: definition for a certain type of object. Object: instance of the class with values filled into the template. E. g. class class_name { number variables: holds its properties/states methods: what it can do: fields. Number variables used to store data in objects. Type of method that set up the object by initializing its values. Has the same name as the class. No return type or void class bicycle { int xpos; int ypos; int xspeed; Bicycle() { xpos = 0; ypos = height/2; xspeed = 5; Bicyle (int xpos, int ypos, int speed) { this. xpos = xpos; [this = refer to itself] this. ypos = ypos; [make distinction between ypos from parameters] [let system know field or parameter we refer to] this. xspeed = this. xspeed; Local variables : variables declared within a method (cannot access outside. Fields (member variables): variables declared within a class (cannot be.

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