当前位置: 移动技术网 > IT编程>软件设计>设计模式 > Matlab单例模式

Matlab单例模式

2019年05月11日  | 移动技术网IT编程  | 我要评论
classdef singletonclass < handle
    methods(access = private)
        function obj = singletonclass()
           disp('singletonclass construtor called!');
        end
    end
    methods(static)
        function obj = getins()
            persistent ins;
            if isempty(ins) || ~isvalid(ins)
                ins = singletonclass();
            end
            obj = ins;
        end
    end
end

  

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网