Constructor must preserve the class of the returned object

6 visualizaciones (últimos 30 días)
Joseph Burgel
Joseph Burgel el 24 de Jun. de 2011
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.

Respuestas (0)

Categorías

Más información sobre Construct and Work with Object Arrays en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by