hello,
how can i call function from another function?
i declare 3 functions which are move_mid ,move_left and move_right
please see this code (it's just my idea and i know i has many syntacs erorr , but my goal is just how a function call some functions)
move_left()
{
cout <<"press 'd' to move back to middle..."<<endl;
cin >> current_position;
if (current_position == 'd')
{
move_mid();
}
else
{
cout<<"wrong"<<endl;
}
}
void move_mid()
{
cout <<"press 'a to move left..."<<endl;
cout <<"press 'd' to move to right..."<<endl;
cin >> current_position;
if (current_position == 'a')
{
move_left();
}
else if (current_position == 'd')
{
move_right();
}
else
{
cout<<"wrong"<<endl;
}
}
as you see above, i cant do this because the function move_mid dosn't declared before the function move_left
if i change it, also still dosn't wrok
so how can i do it?