Understanding the language, error messages, etc.
Wed Jun 24, 2015 9:43 pm
The question is pretty straightforward. I recently came back from a huge break because of exams and now i'm resuming my snake game, but i can't remember how to do this, if i ever even knew how to do this
This is what i wrote:
- Code:
int const * menuChoice[] =
{
singleGame(),
multiGame(),
classicGame(),
changeSettings(),
gameCredits(),
terminate(),
};
but it dosen't work
Wed Jun 24, 2015 10:02 pm
Yeah you can. This is some code for a simple c++ program.
#include <iostream>
using namespace std;
typedef int (*IntFunctionWithOneParameter) (int a);
int function(int a){ return a; }
int functionTimesTwo(int a){ return a*2; }
int functionDivideByTwo(int a){ return a/2; }
void main()
{
IntFunctionWithOneParameter functions[] =
{
function,
functionTimesTwo,
functionDivideByTwo
};
for(int i = 0; i < 3; ++i)
{
cout << functions[i](8) << endl;
}
}
Thu Jun 25, 2015 1:27 pm
And if my functions dont take anything or return anything could i declare it like this?
Typedef void (*arrayFunction);
Sun Jul 19, 2015 6:56 am
Close:
- Code:
typedef void (*arrayFunction)();
Powered by phpBB © phpBB Group.
phpBB Mobile / SEO by Artodia.