| CS 1371 Dept. Presents: |
| OBJECTS | |
|---|---|
| Definition | A software construct that encapsulates behaviors and data |
| Example |
function acct =
BankAccount(data)
if nargin == 0 acct.balance = 0;
acct = class(acct,'BankAccount');
elseif
isa(data,
'BankAccount')
acct = data;
else
acct.balance = data;
acct = class(acct,'BankAccount');
end
In the command window, typing ba = BankAccount would create the object 'ba' of class BankAccount with all the methods associated with it.
|