如何在C ++中调用另一个函数内的函数? [英] How do I call a function inside of another function in C++?

查看:480
本文介绍了如何在C ++中调用另一个函数内的函数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

解决方案


我不知道如何在C ++的另一个函数中调用函数?我认为这是可能的。


我不同意:

  void bar()
{
}

void foo()
{
bar();如果你想使用一个函数,那么你需要使用一个函数,如果你想使用一个函数还没有定义,你必须先声明才能使用它:

  void baz(); //函数声明

void foo()
{
baz();
}

void baz()//函数定义
{
}


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
{
}

这篇关于如何在C ++中调用另一个函数内的函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆