I am overloading the * operator and I am having trouble accessing the array of the object that the method is called on.
ex result = a *b; I am having trouble getting a.
I have to get the whole array and call another method on it to times that array with a single digit.
1 2 3 4 5 6 7 8 9 10 11 12 13
bigint bigint::operator*(bigint b){
bigint result ;
int power = 0 ;
for(int i = ARRAYSIZE-1;i>0;--i){
result = result + a.timesdigit(b.bigintArray[i]);
}
return result ;
}
that a needs to be replaced with something but I do not know what.
I also suggest looking up how to pass by reference (pass variables by reference), because it is much more efficient, and it doesn't create new memory.
Another thing: you call it a "method", and that's not correct. Java has methods, C++ does not. This is a class you are modifying.
here is the prototype for passing by reference to get you started:
bigint operator*(const bigint&); //also look up constant correctness
Also, I would consider ONLY creating addition/subtraction functions, since multiplication/division is only an extension of them, and use those in multiplication/division processes. Of course, this only somthing to consider.
"Method" is general to OOP, "member function" is specific to C++. Which you use depends on whether you're discussing general OOP or specific aspects of C++.
"Method" is general to OOP, "member function" is specific to C++. Which you use depends on whether you're discussing general OOP or specific aspects of C++.
In C++, member functions literally are (static) members of classes.
In Java, the semantics are entirely different, and methods are technically not considered to be actual members of classes (as seen with the Reflection API).