我当前在尝试使用参数对象的方法时遇到错误。
我想做的事:
USING class.Bar.
CLASS class.Foo SERIALIZABLE INHERITS Progress.Lang.Object:
DEFINE PRIVATE VARIABLE cRrk_ID AS CHARACTER NO-UNDO.
CONSTRUCTOR PUBLIC Foo(INPUT objBar AS Bar):
THIS-OBJECT:cRrk_ID = objBar:getRrk_ID(). //Runtime Error: Invalid Handle (3135)
END.
END.
CLASS class.Bar SERIALIZABLE INHERITS Progress.Lang.Object:
DEFINE PRIVATE VARIABLE cRrk_ID AS CHARACTER NO-UNDO.
CONSTRUCTOR PUBLIC Bar(INPUT pcRrk_ID AS CHARACTER):
THIS-OBJECT:cRrk_ID = pcRrk_ID.
END.
METHOD PUBLIC CHARACTER getRrk_ID():
RETURN THIS-OBJECT:cRrk_ID.
END METHOD.
END.
有人能解释为什么当Object的方法是一个参数时,我不能使用它吗?
您需要NEW类。酒吧在课堂上排名第一。Foo的构造函数。
CONSTRUCTOR PUBLIC Foo(INPUT objBar AS Bar):
objBar = NEW class.Bar () .
THIS-OBJECT:cRrk_ID = objBar:getRrk_ID(). //Runtime Error: Invalid Handle (3135)
END.
您可以使用但创建Bar对象并发送到Foo的构造函数:
DEFINE VARIABLE objBar AS "class.Bar" NO-UNDO.
objBar = NEW "class.Bar"("hi").
DEF VARIABLE objFoo AS "class.Foo" NO-UNDO.
objFoo = NEW "class.Foo"(objBar).