calling class into another class
조회 수: 27 (최근 30일)
이전 댓글 표시
Hi guys,
Is there any way to call a class into another class. If so could anyone give me a small example. I want to call the complete class with indenpendent and dependent properties
thankyou
댓글 수: 1
JAMMI ASHOK
2020년 9월 24일
What do you mean by 'calling'?
You can inherit a class to another class - create an object to child class - and using that object access the parent class attributes.
답변 (1개)
Rik
2020년 9월 24일
classdef PositiveDouble < double
methods
function obj = PositiveDouble(data)
if nargin == 0
data = 1;
else
mustBePositive(data)
end
obj = obj@double(data);
end
end
end
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Construct and Work with Object Arrays에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!