Hello,
i was wondering how i can get my program to function... piecing it together bit by bit.
Problem i'm having right now... i'm trying to get my class to point to the array that i have built inside the main function:
char n=5;
char rndseq[]={16,34,57,79,121};
int ntimes=100000;
Prob1Random a(n,rndseq);
here is the header:
// Specification file for the Prob1Random class
#ifndef PROB1RANDOM_H
#define PROB1RANDOM_H
class Prob1Random
{
private:
char *set; //The set of numbers to draw random numbers from
char nset; //The number of variables in the sequence
int *freq; //Frequency of all the random numbers returned
int numRand; //The total number of times the random number function is called
public:
Prob1Random(const char,const char *); //Constructor
~Prob1Random(void); //Destructor
char randFromSet(void); //Returns a random number from the set
int *getFreq(void) const; //Returns the frequency histogram
char *getSet(void) const; //Returns the set used
int getNumRand(void) const; //Gets the number of times randFromSet has
//been called
};
#endif
here is the resource file:
#include <iostream>
#include <string>
#include "Prob1Random.h" // Prob1Random class header
using namespace std;
// Definition of Prob1Random class constructor
Prob1Random::Prob1Random(const char n,const char* rndseq){
nset = n; //Assign number of values to pull random function from
set = rndseq; //Set pointer to random sequence
}
i'm simply trying to get the set pointer inside the class to point to the rndseq array inside my main function. any assistance would be great! thanks.