I've created some mathematical functions that will be used in main() and by member functions in multiple host classes. I was thinking it would be easiest to make these math functions global in scope, but I'm not sure how to do this.
I've currently put all the functions in a file called Rdraws.cpp, with the prototypes in Rdraws.h. Even with all the #includes and externs, I'm getting a "symbol not found" error at the first function call in main().
Here's what I have:
// Rdraws.cpp
#include <cstdlib>
using namespace std;
#include <cmath>
#include "Rdraws.h"
#include "rng.h"
extern RNG rgen // this is the PRNG used in the simulation; global scope
void rmultinom( double p_trans[], int numTrials, int numTrans, int numEachTrans[] )
{ // function 1 def
}
void rmultinom( const double p_trans[], const int numTrials, int numTrans, int numEachTrans[])
{ // function 2 def
}
int rbinom( int nTrials, double pLeaving )
{ // function 3 def
}
// Rdraws.h
#ifndef RDRAWS
#define RDRAWS
void rmultinom( double[], int, int, int[] );
void rmultinom( const double[], const int, int, int[] );
int rbinom( int, double );
#endif
// main.cpp
...
#include "Rdraws.h"
...
extern void rmultinom(double p_trans[], int numTrials, int numTrans, int numEachTrans[]);
extern void rmultinom(const double p_trans[], const int numTrials, int numTrans, int numEachTrans[]);
extern int rbinom( int n, double p );
...
int main() { ... }
I'm pretty new to programming. If there's a dramatically smarter way to do this, I'd love to know.