Is this function correct?

closed account (LN3RX9L8)
int turn_plays(int array [], int boats, int &counts);

Do all functions have to be uniformed or can they be like mine, where only the lost part "counts" is pass by reference) or is this incorrect for c++.

Thanks
Last edited on
I am not sure what you meant here.
But you must do forward declaration if function defined after place where it will be used:
1
2
3
4
5
6
7
8
int do_nothing()
{
}

int main()
{
    do_nothing()
}
Do not need forward declaration: do_nothing() defined before its use in main()


1
2
3
4
5
6
7
8
9
10
int do_nothing(); //Forward declaration. If you delete it, it would be an error

int main()
{
    do_nothing()
}

int do_nothing()
{ //Definition
}
You need to do forward declaration bacause otherwise when compiler encounter function call in mait it wouldn't know that this is correct existing function
Last edited on
The function looks correct. basic data types need not be passed by reference unless they need to be changed.

everything is correct if there is no syntax error. :)
closed account (LN3RX9L8)
Thanks everyone!
Topic archived. No new replies allowed.