calling class into another class

19 ビュー (過去 30 日間)
kanuri venkata mohana
kanuri venkata mohana 2020 年 9 月 8 日
回答済み: Rik 2020 年 9 月 24 日
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
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
Rik 2020 年 9 月 24 日
Here is an example from the documentation:
classdef PositiveDouble < double
methods
function obj = PositiveDouble(data)
if nargin == 0
data = 1;
else
mustBePositive(data)
end
obj = obj@double(data);
end
end
end

カテゴリ

Help Center および File ExchangeConstruct and Work with Object Arrays についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by