Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- obj = obj@MySuperClass(SuperClassArguments);
- classdef subClass < superClass
- properties (Access = public)
- arg1 = 1
- end
- methods
- function obj = subClass(arg1)
- obj = obj@superClass(arg1);
- end
- end
- end
- classdef superClass
- properties (Access = protected)
- arg2
- end
- methods
- function obj = superClass(local_arg1)
- switch local_arg1
- case 1
- obj = functionA();
- otherwise
- obj = functionB();
- end
- end
- end
- end
- function obj = functionA(obj)
- obj.arg2 = 1;
- end
- function obj = functionB(obj)
- obj.arg2 = 2;
- end
- >> a = subClass(1);
- classdef superClass
- properties (Access = protected)
- arg2
- end
- methods
- function obj = superClass(local_arg1)
- switch local_arg1
- case 1
- obj = functionA(obj);
- %Or: obj = obj.functionA();
- otherwise
- obj = functionB(obj);
- %Or: obj = obj.functionB();
- end
- end
- end
- methods (Access = private)
- function obj = functionA(obj)
- obj.arg2 = 1;
- end
- function obj = functionB(obj)
- obj.arg2 = 2;
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement