正如my post所描述的那样,我想创建一个带有never_both函数的UTIL类。
class
UTIL
create
default_create
feature -- could be in class BOOLEAN
double_implies, reversible_implies, never_both (a, b: BOOLEAN): BOOLEAN
-- Into boolean class with never_with
do
if a and b then
Result := False
else
Result := True
end
end
end
使用时
invariant
never_both: {UTIL}.never_both (attached last_error, attached last_success_message)
编译器抱怨有关VUNO
错误
never_both used in the non-object call is not a class feature.
我看到了2种关于对象创建的符号
-{UTIL}.never_both (a, b)
-({UTIL}).never_both (a, b)
它们之间有什么区别?
如果可能,如何在埃菲尔铁塔上创建一个应用程序对象(如果需要,甚至可以在全世界范围内使用)?
我知道这是一个问题,所以我把它们放在 Bold
答案 0 :(得分:2)
如果要使用功能而不创建相应的对象,则应将其标记为class
功能。这是在功能后置条件中使用相同的关键字完成的:
foo ...
do
...
ensure
instance_free: class
...
end
之后,可以在无对象调用{BAR}.foo ...
中使用该功能。
符号({BAR}).qux
并不表示无对象调用。它是对TYPE [BAR]
类型的目标对象的对象调用。该对象描述类型BAR
。