面向对象
classdef Man < handle
properties(Access=private)
score
end
properties
age
height
end
methods
function obj = Man(inputArg1,inputArg2)
obj.age = inputArg1 + inputArg2;
end
function outputArg = method1(obj,inputArg)
outputArg = obj.age + inputArg;
end
function obj=grow(obj,inputArg)
obj.age=obj.age+inputArg;
end
function obj=setScore(obj,inputArg)
obj.score=inputArg;
end
function score=getScore(obj)
score=obj.score;
end
end
end
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
classdef Person < Man
properties
Property1
end
methods
function obj = Person(inputArg1,inputArg2,inputArg3)
obj=obj@Man(inputArg1,inputArg2);
obj.Property1 = inputArg3;
end
function outputArg = method1(obj,inputArg)
outputArg = obj.Property1 + inputArg;
end
end
end
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27