开发者

Practise Questions for Templates,Functors,CallBack functions in 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 som开发者_Python百科e 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.


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.


A good exercise is to replace named functions with anonymous functors. For example, instead of using a predicate such as

bool is_overdrawn(const Account& account)
{
    return !account.is_balanced();
}

, you can synthesize a functor via std::not1(std::mem_fun_ref(&Account::is_balanced)).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜