Constructor must preserve the class of the returned object

조회 수: 8 (최근 30일)
Joseph Burgel
Joseph Burgel 2011년 6월 24일
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