开发者

How do I call a function inside of another function in C++? [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and c开发者_StackOverflow中文版annot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 11 years ago.

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

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜