用C模拟嵌套函数++ [英] Simulating nested functions in C++
本文介绍了用C模拟嵌套函数++的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在C以下code ++工程,考虑我一直使用gcc。
In C the following code works consider I always use gcc.
int foo( int foo_var )
{
/*code*/
int bar( int bar_var )
{
/*code*/
return bar_var;
}
return bar(foo_var);
}
如何才能实现在C ++的GCC编译器嵌套函数相同的功能?不介意这似乎是一个初学者的问题。我是新来这个网站。
How can achieve the same functionality of nested functions in C++ on gcc compiler? Don't mind if this seems like a beginner question. I am new to this site.
推荐答案
打开你的函数成仿函数作为香草萨特建议在这篇文章
Turn your function into a functor as Herb Sutter suggests in this article
这篇关于用C模拟嵌套函数++的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文