Saving all Superclass properties inside one subclass property

1 view (last 30 days)
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]

Accepted Answer

Steven Lord
Steven Lord on 5 Aug 2020
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.
  1 Comment
Ravindra
Ravindra on 5 Aug 2020
Thanks....for clearing the confusion!!
Indeed it suppose to contain an array of features.

Sign in to comment.

More Answers (0)

Products

Community Treasure Hunt

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

Start Hunting!