|
|
类定义改为:5 R' q/ q! Z) G) ~
& Z- d6 p! x% A: N" ?
classdef myClass < handle, ^1 p! p( W$ w ~* J
properties: r: L8 e4 `; |9 H8 f+ A
x;& J1 M$ e1 Z% q7 \" x* K$ h
y;
4 A# s8 u; @; o" x0 [% b- C% b+ y( H) v s;
9 z; L) ?0 r7 [" ^$ a end9 u6 x1 U8 C: @
methods
1 `! D; i* X) e* _, }: d8 b function obj=myClass(a,b)
0 k/ L' t8 i9 X5 i* K6 X7 L$ L obj.x=a;9 U" P% W0 ~8 K
obj.y=b;9 y7 t, m9 ~. h% y
end
8 w, a) P+ }8 e7 t2 G1 O: `8 a$ H) p7 T function myAdd(obj) A0 f" t& W$ V1 I" d
obj.s=obj.x+obj.y4 G7 B6 ?) E% f% X' S
end
1 |) J3 G+ o( H" W( |, ?0 {& l end
5 p; O! I3 M" N/ P8 D/ @7 q; Yend |
|