>
class ComplexVector : public Complex
¿are you sure about that inheritance?
¿what are you doing with the `real' and `imaginary' members that were inherit from `Complex?
>
friend ComplexVector operator+ (const ComplexVector& v1, const ComplexVector& v2);
there you are declaring a non-member function
>
ComplexVector& ComplexVector::operator+ (ComplexVector v1, const ComplexVector& v2)
there you are defining a member function.
that's why it's complaining about «not allowed to use two parameters» (remember that being a member function you also have
this
)
Also, note that you are changing the prototype. You are returning a reference (to a local variable even) and passing the first parameter by copy instead of const reference.
> Would they both be member functions or would it be easier to put them as
> nonmember functions?
overload +=, -=, /=, *=, as member functions
define +, -, /, *, as non-friend non-member function
1 2 3
|
ComplexVector operator+(ComplexVector a, const ComplexVector &b){
return a += b;
}
|
For <<, notice that the left side is not your class, but ostream
so you can't make it a member function (as you don't have access to ostream code)
if you need it to be friend or not, would depend on the interface of your class.
> would I have to use pointers in order to access what is in the vector? I have
> heard of using vector but I have tried and the arithmetic doesn't make sense
> to me
sorry, not follow.
focus on just one operator and make your code compilable, then show your issue.
Also, show your `Complex' class.