【发布时间】:2016-11-29 18:04:02
【问题描述】:
为了声明一个函数原型,我们在外部和顶部声明它,这意味着在函数定义之前。
1- 我想知道为什么 c++ 允许在其他函数定义的主体内声明 prototypes scoped?
2- 如何调用原型在另一个函数体内的函数?
这是一个例子:
#include "stdafx.h"
#include <iostream>
using namespace std;
void Bar()
{
cout << "Bar..." << endl;
void Baz();
}
int main()
{
void Foo();
Foo();
Bar();
Baz(); // how to call this function?
cin.get();
return 0;
}
void Foo()
{
cout << "Foo..." << endl;
}
void Baz()
{
cout << "Baz..." << endl;
}
【问题讨论】: