CS 1112 Lecture 22: Defining Classes

35 views1 pages

Document Summary

Creating an object: constructor methods assign properties to an instance of an object. Has the same name as the class. Has parameters for all properties of the class. Do not need to have the same names as the properties, but can. Example: function obj = object(param1, param2) obj. prop1 = param1; obj. prop2 = param2; end: the handle (reference/pointer in java) is the space of the object in memory. Each object has its own unique handle. Objects are referenced in code using the handle. When a class object is stored in a variable, the variable stores the handle. Say p is a class object, setting s = p gives both values the same handle.

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