createprocess - Eiffel:如何创建和使用 UTIL 类,或 "call static method from class"

标签 createprocess eiffel

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不是类功能。

我看到了 2 个关于对象创建的符号 - {UTIL}.never_both (a, b) - ({UTIL}).never_both (a, b)

它们有什么区别?

如果可能的话,如何在 Eiffel 中创建一个应用程序范围的对象(如果您愿意,甚至可以是世界范围的对象!) 以便使用此 UTIL?!

我知道这是一个问题元组,所以我把它们用粗体

最佳答案

如果您想使用某个功能而不创建相应的对象,则应将其标记为class功能。这是在功能后置条件中使用相同的关键字完成的:

foo ...
    do
          ...
    ensure
        instance_free: class
        ...
    end

之后,该功能可以在无对象调用中使用 {BAR}.foo ...

符号({BAR}).qux并不表示无对象调用。它是对 TYPE [BAR] 类型的目标对象的对象调用。该对象描述了 BAR 类型。

关于createprocess - Eiffel:如何创建和使用 UTIL 类,或 "call static method from class",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52778337/

相关文章:

c++ - 传递给 CreateProcess 的参数未按我预期的那样进行解析

c - eiffel c编译失败: error LNK2001: unresolved external symbol

null - Eiffel 是否避免所有 null 值?

c++ - 开始一个进程而不是 child

c++ - 如何 CreateProcessAsUser 并使其成为前景窗口?

c++ - 无法从通过管道 C++ (Windows) 重定向的程序中获得正确的输出

exception - Eiffel and Rescue子句中的错误处理

c++ - 不直接使用字符串时的CreateProcess @Unhandled异常

c++ - 如何将一大块 native 代码变成可扩展的服务?

compiler-errors - Eiffel :or and and and 中的本地声明编译失败