I've two functions fun() and fun2();
fun() calls itself while incrementing the global variable a=0 and terminates if a==5. But if I call another function called fun2() which basically returns and do nothing, then Build Error happens. Why? I'm just experimenting with recursion and I got this error.
#include<iostream>
using namespace std;
int a = 0;
void fun() {
if (a == 5)
return;
a++;
fun();
fun2(); //This is where the trouble happens
}
void fun2() {
return;
}
int main() {
fun();
return 0;
}
Aucun commentaire:
Enregistrer un commentaire