Saving all Superclass properties inside one subclass property

1 次查看(过去 30 天)
Feature class created with proerties featid & to_delete
classdef Feature < handle
properties (Access = public)
% Unique ID of this feature
featid;
% If this feature should be deleted
to_delete;
end
methods
function obj = Feature()
end
function obj=clean_old_measurements(obj,valid_times)
end
end
end
Sub class FeatureDatabase inherites from Feature class
classdef FeatureDatabase < Feature
properties (Access = public)
% Mtx for our map
mtx;
% Our lookup array that allow use to query based on ID
features_idlookup;
end
methods
function obj = FeatureDatabase()
% Default constructor
obj.features_idlookup = Feature;
end
function obj=cleanup_measurements(obj,timestamp)
end
end
end
The object F is created which uses the methods from Feature class. Below code shows that not only we inherite from Feature class, as well as the all the properties of the Feature class are stored in the features_idlookup.
>> F = FeatureDatabase()
F =
FeatureDatabase with properties:
mtx: []
features_idlookup: [1×1 Feature]
featid: []
to_delete: []
How can I inherite from the superclass and store all the properties only in features_idlookup?
I want to achieve the following. Suggestions and help is appericiated. Thank you in advance.
>> F = FeatureDatabase()
F =
FeatureDatabase with properties:
mtx: []
features_idlookup: [1×1 Feature]

采纳的回答

Steven Lord
Steven Lord 2020-8-5
Should FeatureDatabase inherit from Feature (be a Feature?)
Or should FeatureDatabase have a property that contains an array of Feature objects? In this case, FeatureDatabase should not be a subclass of Feature.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Subclass Definition 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by