How to copy an object that is not a graphic one?
2 ビュー (過去 30 日間)
Matt J 2018 年 4 月 13 日
編集済み: Matt J 2018 年 4 月 13 日
In general, you would have to write a copy() method specific to the needs of your class. The copy() method would have to call the class constructor with suitable arguments to generate a copy.
If your class is sufficiently simple that a copy can be made just by dot-indexing all of the non-Dependent, public property values and writing them to a second object,
objcopy.prop1 = obj.prop1;
objcopy.prop2 = obj.prop2;
then you can just use my attached copyprops() utility, which automates this.