首页 \ 问答 \ 强制执行函数调用的顺序?(enforce order of function calls?)

强制执行函数调用的顺序?(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
更新时间:2021-12-21 11:12

最满意答案

我不知道numberpsymbolp ,布尔类型和其他类型谓词的确切历史,但是对于泛型类型谓词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 predicate typep it is not necessary to have a separate predicate for every type. A short way to see if something is of type boolean is (typep object 'boolean).

相关问答

更多
  • 一个谓词的定义,可以在这里在各种来源在线查找: 一个逻辑表达式,其计算结果为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 ...
  • 这些是不同的概念。 我们正在深入了解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 ...
  • 它看起来像你想要的: static Predicate p(Predicate 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 ...
  • 在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 = ...

相关文章

更多

最新问答

更多
  • 如何在Laravel 5.2中使用paginate与关系?(How to use paginate with relationships in Laravel 5.2?)
  • linux的常用命令干什么用的
  • 由于有四个新控制器,Auth刀片是否有任何变化?(Are there any changes in Auth blades due to four new controllers?)
  • 如何交换返回集中的行?(How to swap rows in a return set?)
  • 在ios 7中的UITableView部分周围绘制边界线(draw borderline around UITableView section in ios 7)
  • 使用Boost.Spirit Qi和Lex时的空白队长(Whitespace skipper when using Boost.Spirit Qi and Lex)
  • Java中的不可变类(Immutable class in Java)
  • WordPress发布查询(WordPress post query)
  • 如何在关系数据库中存储与IPv6兼容的地址(How to store IPv6-compatible address in a relational database)
  • 是否可以检查对象值的条件并返回密钥?(Is it possible to check the condition of a value of an object and JUST return the key?)
  • GEP分段错误LLVM C ++ API(GEP segmentation fault LLVM C++ API)
  • 绑定属性设置器未被调用(Bound Property Setter not getting Called)
  • linux ubuntu14.04版没有那个文件或目录
  • 如何使用JSF EL表达式在param中迭代变量(How to iterate over variable in param using JSF EL expression)
  • 是否有可能在WPF中的一个单独的进程中隔离一些控件?(Is it possible to isolate some controls in a separate process in WPF?)
  • 使用Python 2.7的MSI安装的默认安装目录是什么?(What is the default installation directory with an MSI install of Python 2.7?)
  • 寻求多次出现的表达式(Seeking for more than one occurrence of an expression)
  • ckeditor config.protectedSource不适用于editor.insertHtml上的html元素属性(ckeditor config.protectedSource dont work for html element attributes on editor.insertHtml)
  • linux只知道文件名,不知道在哪个目录,怎么找到文件所在目录
  • Actionscript:检查字符串是否包含域或子域(Actionscript: check if string contains domain or subdomain)
  • 将CouchDB与AJAX一起使用是否安全?(Is it safe to use CouchDB with AJAX?)
  • 懒惰地初始化AutoMapper(Lazily initializing AutoMapper)
  • 使用hasclass为多个div与一个按钮问题(using hasclass for multiple divs with one button Problems)
  • Windows Phone 7:检查资源是否存在(Windows Phone 7: Check If Resource Exists)
  • 无法在新线程中从FREContext调用getActivity()?(Can't call getActivity() from FREContext in a new thread?)
  • 在Alpine上升级到postgres96(/ usr / bin / pg_dump:没有这样的文件或目录)(Upgrade to postgres96 on Alpine (/usr/bin/pg_dump: No such file or directory))
  • 如何按部门显示报告(How to display a report by Department wise)
  • Facebook墙贴在需要访问令牌密钥后无法正常工作(Facebook wall post not working after access token key required)
  • Javascript - 如何在不擦除输入的情况下更改标签的innerText(Javascript - how to change innerText of label while not wiping out the input)
  • WooCommerce / WordPress - 不显示具有特定标题的产品(WooCommerce/WordPress - Products with specific titles are not displayed)