BIGINT part II

what are these classes this is a code snip from a program I am doing for homework creating a big int calculator. I do not know how they all tie together or relate anyone ??? thnaks.

BigInt BigInt::operator+(const BigInt& rightOperand) const {
return add(rightOperand);
}

BigInt BigInt::subtract(const BigInt& rightOperand) const {
BigInt objToReturn;
//Do subtract logic here

return objToReturn;
}

BigInt BigInt::operator-(const BigInt& rightOperand) const {
return subtract(rightOperand);
these are classes with bigint being passed in by reference???
and the values are const???? and light or a step by step would be great..
Do not write it like so:
1
2
3
BigInt BigInt::operator+(const BigInt& rightOperand) const {
return add(rightOperand);
}

It usually looks like this:
1
2
3
4
BigInt &BigInt::operator+(const BigInt& rightOperand) { // Note the additional & and removal of const
add(rightOperand); // Do not return add
return *this; // return this in order to achieve bi1 + bi2 + bi3 ...
}


subtraction is completely equivalent
+= looks like that, not +
coder777 wrote:
Do not write it like so:


That is the correct way to write operator+. It looks like you're thinking more of operator+=.
I did not write this code this was given to us from the teacher we are just suppose to finish it, question am i looking at this right
1
2
3
BigInt BigInt::operator+(const BigInt& rightOperand) const {
return add(rightOperand);
}

this is a Bigint class creating a Bigint object with a method operator + passing in a constant BigInt by reference (num array ) and a rightOperand that is also a constant. how do i get it to return? do i load add?
Topic archived. No new replies allowed.