我有一个名为ErrorItem的类,它有多个construtors。是否可以在构造函数内调用另一个构造函数来管理默认值?
示例:
CONSTRUCTOR PUBLIC ErrorItem():
ErrorItem("", "", "", -1, "", "").
END CONSTRUCTOR.
CONSTRUCTOR PUBLIC ErrorItem(
ItemNo AS CHARACTER
,UpcCode AS CHARACTER
,CustomerPo AS CHARACTER
,ColumnId AS INTEGER
,Description AS CHARACTER):
ErrorItem(ItemNo, UpcCode, CustomerPo, ColumnId, Description, "").
END CONSTRUCTOR.
CONSTRUCTOR PUBLIC ErrorItem(
ItemNo AS CHARACTER
,UpcCode AS CHARACTER
,CustomerPo AS CHARACTER
,ColumnId AS INTEGER
,Description AS CHARACTER
,Detail AS CHARACTER
):
ASSIGN
THIS-OBJECT:ItemNo = ItemNo
THIS-OBJECT:UpcCode = UpcCode
THIS-OBJECT:CustomerPo = CustomerPo
THIS-OBJECT:ColumnId = ColumnId
THIS-OBJECT:Description = Description
THIS-OBJECT:Detail = Detail
.
END CONSTRUCTOR.
谢谢! 的Sebastien
答案 0 :(得分:5)
是 - 格式为:
CONSTRUCTOR PUBLIC ErrorItem(variable list):
THIS-OBJECT(local variable list).
/* Stuff */
END CONSTRUCTOR.
“THIS-OBJECT”调用也必须是构造函数中的第一个语句。