Constructor must preserve the class of the returned object

8 次查看(过去 30 天)
I've created a object, saved it to a file and loaded the object from the file and I get this error:
Warning: Error loading an object of class 'Param.clsParameter': When constructing an instance of class 'Param.clsParameter', the constructor must preserve the class of the returned object.
I do not have the construct on load switch set and I'm subclassing hgsetget. How is the constructor even involved on load? What I gather from: http://www.mathworks.com/help/techdoc/matlab_oop/bres1y6.html#br0li_j
is that is shouldn't be ?
From the page:
When loading objects from MAT-files the load function:
Creates a new object.
Calls the class constructor with no arguments only if the class's ConstructOnLoad attribute is set to true.
Assigns the saved values to the object's properties. These assignments results in calls to property set methods defined by the class.
How can the load process create a new object without calling the constructor?
Very difficult to debug this error.

回答(0 个)

类别

Help CenterFile 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!

Translated by