I have two functions that is dependent on each other, but the order of the function in C++ limit my ability to write reusable codes. For example let say, I want to use functionA in a functionB then
functionB has to be above functionA.
but what if
functionB is using functionA and functionA is using functionB as well? it will gives error
Here's the code, and the order of the functions in c++
void getAnswer(string answer) {
mainProgram();
}
void mainProgram() {
getAnswer("awesome");
}
int _tmain(int argc, _TCHAR* argv[])
{
mainProgram();
return 0;
}
As you can see mainProgram() is using getAnswer() function and vice versa.
I can just solve this problem by deleting the getAnswer() function and simply throw every code from getAnswer() to mainProgram() but the problem with that , is I will write a repetitive code for about 5 times, and it will look really messy.