Can I create a new operator in C++ and how?

前端 未结 9 957
耶瑟儿~
耶瑟儿~ 2020-11-27 18:43

MATLAB arrays support matrix operations and element operations. For example, M*N and M.*N. This is a quite intuitive way to distinguish ‎the two di

9条回答
  •  借酒劲吻你
    2020-11-27 18:45

    It's as simple (and as difficult!) as defining a function named (in this case) operator*():

    Matrix operator*(const Matrix &m1, const Matrix &m2) ...
    

    where Matrix is a class you've defined to represent matrices.

提交回复
热议问题