How do I call a function inside of another function in C++?
I don't think this is possible.
I disagree:
void bar()
{
}
void foo()
{
bar(); // there, I use bar inside foo
}
If you want to use a function that hasn't been defined yet, you must declare it before you can use it:
void baz(); // function declaration
void foo()
{
baz();
}
void baz() // function definition
{
}
you can do so by using lambda
, new feature on the new standard C++0x
int main()
{
auto square = [&](int x) { return x*x; };
auto a = square(3);
return 0;
}
http://www2.research.att.com/~bs/C++0xFAQ.html#lambda
精彩评论