C++ 如何使一个void函数与C++;?
我把C++ 如何使一个void函数与C++;?,c++,C++,我把'(RE)放在void F()中,但我的程序遇到了一个有趣的问题。当我把(RE)放在我的voidF()中时,我的void RE()是在void F()上面编码的,那么void RE()如何才能知道void F()?Visual Studio不允许我以这种方式运行程序。我认为它们在main()之外被声明为void函数,所以我认为它们在任何地方都可以工作 . . . . . void F() { if (nextChar() == 'a') match('a');
'(RE)
放在void F()
中,但我的程序遇到了一个有趣的问题。当我把(RE)
放在我的voidF()
中时,我的void RE()
是在void F()
上面编码的,那么void RE()
如何才能知道void F()
?Visual Studio不允许我以这种方式运行程序。我认为它们在main()
之外被声明为void函数,所以我认为它们在任何地方都可以工作
.
.
.
.
.
void F()
{
if (nextChar() == 'a')
match('a');
else if (nextChar() == 'b')
match('b');
else if (nextChar() == 'c')
match('c');
else if (nextChar() == 'd')
match('d');
else if (nextChar() == 'a')
{
match('(');
RE(); //HOW????
match(')');
}
}
void RE()
{
if (nextChar() == 'a')
{
RE();
RE();
}
else if (nextChar() == 'a')
{
RE();
match('|');
RE();
}
else if (nextChar() == 'a')
{
RE();
match('*');
}
else if (nextChar() == 'a')
F(); //How????
}
int main()
将
RE()
的声明放在F()
之前:
将
RE()
的声明放在F()
之前:
函数可以具有和。要能够调用函数,代码所需要的只是能够看到一个声明
因此,为RE
和F
提供声明,然后定义它们
void RE();
void F();
//RE and F definitions here.
函数可以具有和。要能够调用函数,代码所需要的只是能够看到一个声明
因此,为RE
和F
提供声明,然后定义它们
void RE();
void F();
//RE and F definitions here.
哦,上帝。。。。为什么我要费心问这个。。。。我的大脑最近一直在昏睡。非常感谢。哦,上帝。。。。为什么我要费心问这个。。。。我的大脑最近一直在昏睡。非常感谢你。