Saving all Superclass properties inside one subclass property
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Ravindra
am 5 Aug. 2020
Kommentiert: Ravindra
am 5 Aug. 2020
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]
0 Kommentare
Akzeptierte Antwort
Steven Lord
am 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.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Subclass Definition finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!