Let's see some more code please. You don't have to use pointers.
iamthwee
Posting Expert
5,950 posts since Aug 2005
Reputation Points: 1,543
Solved Threads: 439
I must be looking at this completely wrong because to me it looks like you pass the sum and cBit into the function, but I though that is what the function is suppose to produce.
sum and cbit are values returned back to the calling function. Your function will load these values with the answers.
I am confused with pointers and references, I dont really understand why they are being used in this situation.
Because the instructor said so. ;)
Pointers are simply another way to access an array. Read up on them and ask specific questions about them and we can help you. This link has some information about pointers vs. arrays.
WaltP
Posting Sage w/ dash of thyme
10,506 posts since May 2006
Reputation Points: 3,348
Solved Threads: 944
> because to me it looks like you pass the sum and cBit into the function
Well one is a pointer, and the other is a reference. So they could both be used for input, input/output or output.
The other two parameters are declared const, so that just makes them inputs.
int a[8] = { 0, 0, 0, 0, 0, 0, 0, 1 };
int b[8] = { 0, 0, 0, 0, 0, 0, 0, 1 };
int result[8];
int carry = 0;
binaryAdd( result, carry, a, b);
// now print out result and carry
// a and b will not be changed
Salem
Posting Sage
11,531 posts since Dec 2005
Reputation Points: 5,862
Solved Threads: 953