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.
For the syntax of "Matrix & operator +":
"Matrix &" means that the resulting matrix (*this) is returned using "pass by reference"; Of course you can also use "pass by value" or "pass by pointer". I used "pass by reference" here in order to consume less memory.
"operator" is a fixed keyword;
"+" is the operator that to be overloaded.
The type of "y.a" is vector >, which means a vector of VECTORS. "y.a.size()" is the size of vector, while "y.a[0].size()" is the size of VECTOR. The capital VECTOR here has no other meanings but only to distinguish from vector.
"this" is the pointer (Matrix *) of the current obj.
"*this" is the content (Matrix) of the current obj.
Welcome more questions if the above explanation is not clear or has mistakes.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Find the Running Median
You are viewing a single comment's thread. Return to all comments →
Hi, wrodgers,
For the syntax of "Matrix & operator +":
"Matrix &" means that the resulting matrix (*this) is returned using "pass by reference"; Of course you can also use "pass by value" or "pass by pointer". I used "pass by reference" here in order to consume less memory.
"operator" is a fixed keyword;
"+" is the operator that to be overloaded.
The type of "y.a" is vector >, which means a vector of VECTORS. "y.a.size()" is the size of vector, while "y.a[0].size()" is the size of VECTOR. The capital VECTOR here has no other meanings but only to distinguish from vector.
"this" is the pointer (Matrix *) of the current obj. "*this" is the content (Matrix) of the current obj.
Welcome more questions if the above explanation is not clear or has mistakes.