Algorithm needed

I'm banging my head on this one.

I have one more function to write for a project, and I just can't figure it out. I have to take in 2 integer arrays that represent 8 bit integers, and do a bitwise AND on them. I have to return them as a const BitPattern (which is the class I'm using).

1
2
3
4
5
6
7
8
9
10
11
//this is the prototype
// bit manipulation functions on two bit patterns
// these all return an anonymous object as a result and do not print result
const BitPattern Operation_AND (const BitPattern&) const;

//function definition
const BitPattern BitPattern::Operation_AND (const BitPattern&) const {

//code needed to do a BITWISE AND and return it

}


I'm also not sure why this function only takes in 1 parameter, when I need to compare 2. I can figure that out if someone can guide me in the right direction with an algorithm.
The reason that it takes only one parameter is that the other parameter is the object upon which it is being called.

Let's expand this out:

1
2
3
4
5
6
7
BitPattern X;
BitPattern Y;

// what we want is Z = X & Y
// what we get when fully qualified is:

const BitPattern Z = X::Operation_AND(Y);


Does that make more sense?

You will see this a lot in operators. It will seem like one of the operands is missing because the object that is being used to access the operator is one of the operands.

Xen
Duh! *facepalm*

Totally understand it now, Thanks!
Topic archived. No new replies allowed.