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+
$40 USD/m
Billed monthly
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
10 Verified Answers
Class+
$30 USD/m
Billed monthly
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
7 Verified Answers

Related Documents

Related Questions