C++ project, arrays to objects and functions.

Okay, I am working on a C++ project but I need some help. Here are my instructions:

//////////////////

Write a class called Individual.
The class contains a Boolean array (const int size = 10) internally (private)
whose values are randomly generated inside constructor. (Hint: use
member initializer to assign 10 to const int size)
The class has a function, called and, which takes in another individual
object and return this object (hint: *this) whose Boolean array contains the
result of AND from two Boolean array. If two objects have different array
sizes, compute and using the smaller size. For example:

Individual object1 has 1001010110 in its internal array.
Individual object2 has 0001011011 in its internal array.

After executing the following statement:
object1.AND(object2);
The internal array of object1 becomes 0001010010.
object2’s array remains unchanged.

//////////////

I am not sure how to give objects arrays or how to setup the And function. Here is my coding so far:

///////////////
(header)
#include <iostream>
#include <ctime>
#include <cstdlib>
using namespace std;

class Individual
{
public:
Individual();
~Individual();
void And();

private:
bool barray[10];
};
--------------------------------------------------
(cpp)
#include <iostream>
#include <ctime>
#include <cstdlib>
#include "Individual.h"
using namespace std;

Individual::Individual()
{
srand((unsigned)time(0));
int keeper;
int blue = 0;
for(int i=0; i<10; i++)
{
keeper = (rand()%2);
barray[blue] = keeper;
blue++;
}
}

Individual::~Individual()
{
}

void Individual::And()
{

}
-------------------------------------------------
(driver/main cpp)
#include <iostream>
#include <ctime>
#include <cstdlib>
#include "Individual.h";

int main ()
{
Individual object1;
Individual object2;

object1.And();
return 0;
}
//////////////////

Any help is greatly appreciated.


Topic archived. No new replies allowed.