I created some math functions that will be used in main () and member functions in several host classes. I thought it would be easiest to make these mathematical functions global, but I'm not sure how to do this.
Currently, I put all the functions in a Rdraws.cpp file with prototypes in Rdraws.h. Even with all #includesand externs, I get a compiler error "character not found" when I first call the function in main ().
Here is what I have:
#include <cstdlib>
using namespace std;
#include <cmath>
#include "Rdraws.h"
#include "rng.h"
extern RNG rgen
void rmultinom( double p_trans[], int numTrials, int numTrans, int numEachTrans[] )
{
}
void rmultinom( const double p_trans[], const int numTrials, int numTrans, int numEachTrans[])
{
}
int rbinom( int nTrials, double pLeaving )
{
}
#ifndef RDRAWS
#define RDRAWS
void rmultinom( double[], int, int, int[] );
void rmultinom( const double[], const int, int, int[] );
int rbinom( int, double );
#endif
...
#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 );
RNG rgen;
int main() { ... }
I am new to programming. If there is a more reasonable way to do this, I would like to know.
Update
I am an idiot and do not understand that I have not yet included Rdraws.cpp in my compiler. As the poster noted, I also forgot the semicolon.
, .