Hello I have got 2 questions.
1) I have got math vector which is saved as table. Got dim. I want to overload + and += operators. I have no problem with overloading the += operator, but what should I do if I want to overload the + operator? Should I return a new object of MathVector?
Code for += overload:
MathVector & operator+=(MathVector & o){
for(int i=0; i<dim; i++){
this->tab[i]+=o.tab[i];
}
return *this;
}
2) If I want to save the result from:
MathVector v1(3);
MathVector v2(3);
v1.fill(); // fill from basic input
v2.fill();
MathVector result;
result=v1+v2;
Should I make special overload for = operator? And another one if I want make something like v1+a (a is integer) ?