汽车电子 - matlab - 用法

汽车电子 - matlab - 用法

面向对象

matlab 复制代码
% Man.m
classdef Man < handle
    %UNTITLED2 此处显示有关此类的摘要
    %   此处显示详细说明

    properties(Access=private) %私有变量
        score
    end
    properties
        age
        height
    end

    methods
        function obj = Man(inputArg1,inputArg2)
            %UNTITLED2 构造此类的实例
            %   此处显示详细说明
            obj.age = inputArg1 + inputArg2;
        end

        function outputArg = method1(obj,inputArg)
            %METHOD1 此处显示有关此方法的摘要
            %   此处显示详细说明
            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
matlab 复制代码
% Person 继承自 Man
classdef Person < Man
    %PERSON 此处显示有关此类的摘要
    %   此处显示详细说明
    
    properties
        Property1
    end
    
    methods
        function obj = Person(inputArg1,inputArg2,inputArg3)
            %PERSON 构造此类的实例
            %   此处显示详细说明
            obj=obj@Man(inputArg1,inputArg2);

            obj.Property1 = inputArg3;
        end
        
        function outputArg = method1(obj,inputArg)
            %METHOD1 此处显示有关此方法的摘要
            %   此处显示详细说明
            outputArg = obj.Property1 + inputArg;
        end
    end
end
相关推荐
Brilliantwxx10 分钟前
【C++】深度剖析 · 继承 (虚基表+虚函数表)
开发语言·c++
砍材农夫11 分钟前
物联网 基于netty构建mqtt协议规范(发布/订阅模式)
java·开发语言·物联网·netty
techdashen12 分钟前
Rust 泛型 vs Java 泛型:它们看起来相似,但骨子里截然不同
java·开发语言·rust
一只旭宝16 分钟前
【C加加入门精讲15】:IO流缓冲区、字符串流、缓冲流及STL vector容器零基础实战教程一、博客前言
开发语言·c++
在坚持一下我可没意见28 分钟前
Python 修仙修炼录 08:字典秘境,参悟键值玄机
开发语言·笔记·python·入门·字典
这个名字先用着29 分钟前
形位公差详解
学习·汽车·制造
luck_bor30 分钟前
Map&Stream流
java·开发语言
阿文的代码库32 分钟前
如何在C++中使用标准库的智能指针
开发语言·c++·算法
绿蕉34 分钟前
2026年汽车
汽车
yujunl34 分钟前
U9客开Demo代码中的错误
开发语言