I'm doing c++ with different function. I want to put the function in different source file. To do I create a header file:
function.h
int X(int i, int k);
and the file with the function:
function.cpp
int X(int i, int k){
return p + (i-1)*(n-1) + (k-1);
}
and I have my main :
#include "subfunction.h"
int p, n, m, num_entries, NUMROWS;
int main (int argc, char **argv){
int project = 4;
int employee = 5;
int time = 5;
p=project;
n=employee;
m=time;
num_entries=-1;
int row=-1;
M[num_entries].col=X(i,k);
}
I didn't put all my main, just the interesting part. My problem is that n,m and p are global variable in my main but I also used them in my function. If I declare it in the function, the main doesn't work anymore and same if I declare in the main.
How I can do it using the global variable? Thanks