强制执行函数调用的顺序?(enforce order of function calls?)
假设我有一个抽象基类,我想要一个纯粹的虚方法,它必须由派生类实现,但我想确保派生方法以特定顺序调用函数,我可以如何执行它?
IE
base class virtual void doABC()=0; virtual void A()=0; virtual void B()=0; virtual void C()=0; // must call ABC in the correct order derived class public base void doABC();
这就是为什么我更好地理解如何设计我的类来强制某人正确使用我的类。
Say I have a abstract base class and I want to have a pure virtual method which must be implemented by the derived class but I want to make sure that the derived method calls functions in a particular order what could I do to enforce it ?
I.E
base class virtual void doABC()=0; virtual void A()=0; virtual void B()=0; virtual void C()=0; // must call ABC in the correct order derived class public base void doABC();
This is just so I have a better understanding on how to design my classes to enforce someone to use my class correctly.
原文:https://stackoverflow.com/questions/10601943
最满意答案
我不知道
numberp
,symbolp
,布尔类型和其他类型谓词的确切历史,但是对于泛型类型谓词typep
的可用性,没有必要对每个类型都有单独的谓词。 查看某些boolean
类型的简短方法是(typep object 'boolean)
。I don't know the exact history of
numberp
,symbolp
, the boolean type, and other type predicates, but with the availability of the generic type predicatetypep
it is not necessary to have a separate predicate for every type. A short way to see if something is of typeboolean
is(typep object 'boolean)
.
相关问答
更多-
什么是谓词?(What is a predicate?)[2023-05-29]
一个谓词的定义,可以在这里在各种来源在线查找: 一个逻辑表达式,其计算结果为TRUE或FALSE,通常用于指导代码中的执行路径。 参考: 软件测试。 马修·海登 The definition of a predicate, which can be found online in various sources such as here, is: A logical expression which evaluates to TRUE or FALSE, normally to direct the exe ... -
探究剩余与加入谓词(Probe Residual vs Join Predicate)[2023-10-04]
这些是不同的概念。 我们正在深入了解SQL Server如何计划它的查询的细节,而不是那些让人胆战心惊的地方! 但非常有趣的是,如果你正在研究这个领域,你将不会成为一个“小老鼠”。 本文描述了如何将一些谓词解释为“寻找”,首先排除许多行,以便只有少数谓词需要检查以确定它们是否与谓词的其余部分相匹配 - 残留谓词。 本文介绍如何处理连接,以及查询的详细信息如何导致关于是否存在连接谓词的决定,从根本上影响性能。 These are distinct concepts. We're right into the ... -
很难弄清楚到底在找什么,但我必须说它看起来非常像家庭作业。 这是你想要的? create_nbStation(L) :- compte(L, N), assert(nbStation(L, N)). It is quite difficult to figure out what exactly you are looking for, but I must say it does look very much like homework assignment. Is this what you are ...
-
还有方便 all :: (a -> Bool) -> [a] -> Bool 它可以用来编写你的功能 find (all isDigit) There is also the handy all :: (a -> Bool) -> [a] -> Bool which can be used to write your function find (all isDigit)
-
我不知道numberp , symbolp ,布尔类型和其他类型谓词的确切历史,但是对于泛型类型谓词typep的可用性,没有必要对每个类型都有单独的谓词。 查看某些boolean类型的简短方法是(typep object 'boolean) 。 I don't know the exact history of numberp, symbolp, the boolean type, and other type predicates, but with the availability of the gen ...
-
您正在寻找的一般术语是“代表” 。 虽然你不能直接做一些像predicate(item) = someValue; 在C#中,您可以使用Action和/或Func来执行您要执行的操作。 获取价值是更常见的做事方式,例如LINQ的Select可以实现如下: public static IEnumerable
Select ( this IEnumerable source, Func se ... -
Łukasiewicz谓词逻辑?(Łukasiewicz predicate logic?)[2020-02-10]
它看起来像你想要的: staticPredicate p(Predicate super T> o){ //(I'm not sure what to name this) return new Predicate (){ @Override public boolean test(T t) { return t == null || o.test(t); } @Override ... -
嗯,你从你的函数中返回具体的值,并且它们中没有任何模糊,你在三值逻辑域(有时称为三价)比在模糊域中更多。 例如,三价在电子(三态逻辑)中非常流行。 设备可以处于3种状态:逻辑1(真),逻辑0(假)和高阻抗。 Hm, you are returning concrete values from your function, and there is nothing fuzzy in them, you are more in three-valued logic domain (sometimes calle ...
-
获取调用谓词的名称(Get the name of the calling predicate)[2022-06-24]
在SWI-Prolog检查库(prolog_stack) 。 特别是,以下谓词的组合应该可以满足您的需求: get_prolog_backtrace/2 prolog_stack_frame_property/2 请注意 :这不容易移植到其他Prolog系统,并且很可能有更优雅,更有效的方式来满足您的需求。 例如,执行所描述的一种方法是使用term_expansion/2 :您可以通过其中一个参数表示调用上下文的方式扩展特定目标。 这在运行时非常便携,非常高效,您可以静态检查生成的扩展。 In SWI-Pr ... -
我没有重新编写,但看起来问题部分在于你使表达式比示例更复杂。 作为建议,请尝试: public IEnumerable
Find (Expression > expression, TValue value) { using (IDbConnection cn = GetCn()) { cn.Open(); var predicate = ...