self& operator-=(const self& x) { m -= x.m; return *this; }
self& operator+={value_type x) { m += x; return *this; }
self& operator-=(value_type x) { m -= x; return *this; }
self& operator*=(value_type x) { m *= x; return *this; }
self& operator/=(value_type x) { m /= x; return *this; }
self operator-() { return self(-m); }
// друзья
friend self operator+(self x, const self& у) { return x += y; }
friend self operator-(self x, const self& y) { return x -= y; }
friend self operator+(self x, value_type y) { return x += y; }
friend self operator-(self x, value type y) { return x -= y; }
friend self operator*(self x, value_type y) { return x *= y; }
friend self operator/(self x, value_type y) { return x /= y; }
friend bool operator==(const self& x, const self& y) { return x == y; }
friend bool operator!=(const self& x, const self& y) { return x.m != y.m; }
private:
kvector<Value_T, (Rows_N + 1) * Cols_N> m;
};
#endif
В примере 11.31 приведена программа, демонстрирующая применение шаблонного класса kmatrix.
Пример 11.31. Применение kmatrix
#include "kmatrix.hpp"
#include <iostream>
using namespace std;
template<class Iter_T>
void outputRowOrColumn(Iter_T iter, int n) {
for (int i=0; i < n; ++i) {
cout << iter[i] << " ";
}
cout << endl;