We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
- Prepare
- C++
- Other Concepts
- Operator Overloading
- Discussions
Operator Overloading
Operator Overloading
Sort by
recency
|
218 Discussions
|
Please Login in order to post a comment
thought a will be vector (int) , actually was vector (vector (int)).
int a must be public member, otherwise cannot be accessed from outside the class.
idk why, v[i] = a[i][j] + y.a[i][j] didnt work, changed it to v.push_back(a[i][j] + y.a[i][j]) then it worked.
class Matrix { public: vector> a; Matrix(){}; Matrix operator +(Matrix const &x){ Matrix r; r.a = this->a;
};
This works for me. The r.a = this->a created a reference point which will permit in avoiding the overload of recreating another matrix with all the rows and columns.
class Matrix { public: vector> a; Matrix(){}; Matrix operator +(Matrix const &x){ Matrix r; r.a = this->a;
};
I opted to make
Matrix
a struct, since we are forced to make its data public.Could someone tell me what wrong with the below code: