class line: public mallok {
public: short *data; int X; private: public: void create(int X) { data = (short *)mallok::alloc_1d(X,sizeof(short)); this->X = X; } void destroy() { mallok::free_1d(data); } line(int X) { create(X); } ~line() { destroy(); } short & operator[](int x) { return data[x]; } void set_size(int X) { if(!data) data = (short *)mallok::alloc_1d(X, sizeof(short)); this->X = X; } /* Sobrecarga del operador de asignación entre líneas. */ line & operator=(const line & right) { set_size(right.X); for(int x=0; x<X; x++) { data[x] = right.data[x]; } return *this; } /*const*/ line operator+(const line & right) { line tmp(right.X); for(int x=0; x<X; x++) { tmp.data[x] = data[x] + right.data[x]; } return tmp; } /*const*/ line operator-(const line & right) { line tmp(right.X); for(int x=0; x<X; x++) { tmp.data[x] = data[x] - right.data[x]; } return tmp; } /*const*/ line operator/(const int val) { line tmp(X); for(int x=0; x<X; x++) { tmp.data[x] = data[x] / val; } return tmp; } }; |