How to add function prototypes?

Hi all, I'm new here and needed some assistance regarding this program I'm writing.
I'm trying to make the 2048 in c++ and I'm using switch statements to control movement.

However, I'm not sure how to add a function's prototype return value to an integer variable.

For example, if I have a function prototype declared as int shiftDown();
and I have to later add that function prototype to a variable called move, how would I do that?

This is what I have now, but it does not work.

case 'w':
{
moved = shiftUp();
moved += sumUp();
moved += shiftUp();
}

That was basically my wild guess at it. I've looked around and can't seem to find anything specifically regarding this.

Thanks all.
If the function looks like:
1
2
3
4
int shiftUp()
{
    // code
}
then the prototype is:
 
int shiftUp();
When I first declared it, it was just int shiftUp();

Nothing else

EDIT: so If I were to add stuff to it, I would just use

int shiftUp();
{
moved += shiftUp();
}

?
Last edited on
No. That function is calling itself. It's called recursion and is a powerful technique when used appropriately. But you're not using it appropriately.

Why are you making it call itself?
closed account (E0p9LyTq)
However, I'm not sure how to add a function's prototype return value to an integer variable.


http://www.cplusplus.com/doc/tutorial/functions/

http://www.learncpp.com/cpp-tutorial/17-forward-declarations/
Topic archived. No new replies allowed.