it would be wonderful if i could implement a generalized unit class, but as simple of a concept as it is, a good way to implement it eludes me...
here's what i have so far, obviously it's clumsy and woefully inadequate, but at least it's a starting point for some discussion.
there has got to be a more elegant and robust way of doing this. any suggestions (including 3rd party wares) would be greatly appreciated.Code:class unit { public: unit(size_t NumUnits) : numUnits(NumUnits){} double exponent; double coeff; const size_t numUnits; unit *units; double convert(unit u) { //returns a conversion factor if this and u are of compatible dimensions }; unit multiply(unit u) { //adds exponents of this->units of this and u->units } unit divide(unit u) { //subtracts exponents of this->units of and u->units } };