Hi,in which situations pointers to functions might be moreefficient/convenient than a direct function call?In the example I''ve found so far, I see no advantage ofusing pointers to functions. Rather the code is harder toread.Regards,Chris 解决方案Christian Christmann wrote: Hi, in which situations pointers to functions might be more efficient/convenient than a direct function call? In the example I''ve found so far, I see no advantage of using pointers to functions. Rather the code is harder to read.I suggest you study the `qsort()` (or `bsearch()`) function, especiallythe bit where you can pass a pointer to your own comparison function.Christian Christmann wrote: Hi, in which situations pointers to functions might be more efficient/convenient than a direct function call? In the example I''ve found so far, I see no advantage of using pointers to functions. Rather the code is harder to read.Try writing a sort algorithm that works on arbitrary datatypes."Christian Christmann" <pl*****@yahoo.de> wrote in messagenews:pa****************************@yahoo.de... Hi, in which situations pointers to functions might be more efficient/convenient than a direct function call? In the example I''ve found so far, I see no advantage of using pointers to functions. Rather the code is harder to read. Regards, ChrisI have used them in an Artificial Neural Network implementation. ANNsrequire an activation function to normalise the inputs to a given range. Itis desirable to have this definable depending on the problem so usingpointers to functions is applicable and indeed faster considering thisoperation will be executed many times.As for the code being harder to read, I think the declarations are confusingat first but they are fine once you know how. Remember back to learning C,I bet normal pointers were difficult to read too ;-)Allan 这篇关于指向功能的指针的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
07-23 06:45