c++ 中模板、函子、回调函数的练习题?
过去一周我一直在阅读模板、函子、回调函数,并参考了一些好书和文章。
然而,我觉得,除非我能得到良好的实践 - 在模板中编程并使用函子回调,否则我无法真正理解所有概念或在编码时流利地使用它们。
任何人都可以建议一些文章、书籍或网站,其中有问题的定义以及相同的解决方案。我可以只为问题编写代码,然后检查我的解决方案是否足够好。
我还知道我们的一些堆栈溢出成员是模板和回调函数方面的专家。如果他们能够设计一个问题并发布一个解决方案,那就太好了,这样很多像我这样的模板初学者都可以受益。
I have been reading templates,functors,callback function for the past week and have referred some good books and articles.
I however feel that, unless I can get good practice - programming in templates and use functors-callbacks there is no way I can really understand all the concepts or fluently use them while coding.
Could anyone suggest some articles or books or websites where , there is a definition of the problem and also a solution to the same. I could just write code for the problem and check later on if my solution is good enough..
I am also aware that some of our stack-overflow members are experts in templates and callback functions. It would be great if they could design a problem and also post a solution , where a lot of template beginners like me could benefit.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我个人认为这是学习任何东西的错误方法。准备解决此类问题的人几乎肯定不是该技术的专家。最好的学习方法是找到对您来说重要的现实问题,然后使用技术解决问题,并通过阅读文本和参考书以及在此类网站上发布相关问题来支持。
I personally think this is the wrong way to learn anything. The kind of people that will be prepared to set such problems will almost certainly not be the kinds of people who are experts on the technology. The best way to learn is to find a real-world problem that is important to you, and then address the problem using the technology., backed up by reading text and reference books, and by posting relevant questions on sites like this.
一个很好的练习是用匿名函子替换命名函数。例如,
您可以通过
std::not1(std::mem_fun_ref(&Account::is_balanced)) 合成函子,而不是使用诸如 之类的谓词。
A good exercise is to replace named functions with anonymous functors. For example, instead of using a predicate such as
, you can synthesize a functor via
std::not1(std::mem_fun_ref(&Account::is_balanced))
.