Advertisement
lukibeni

foslézer

Mar 8th, 2014
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.63 KB | None | 0 0
  1. #include "resistor.h"
  2.  
  3. double Resistor::defR = 163.0;
  4.  
  5. Resistor::Resistor(){ R = defR; }
  6.  
  7. Resistor::Resistor(double r) { R = r; }
  8.  
  9. void Resistor::setDef(double b = 163.0) { defR = b; }
  10.  
  11. Resistor Resistor::operator+(const Resistor& r) const {
  12.     Resistor result(*this);
  13.     result.R+=r.R;
  14.     return result;
  15. }
  16.  
  17. Resistor Resistor::operator%(const Resistor& r) const {
  18.     Resistor result;
  19.     result.R=1/((1/this->R)+(1/r.R));
  20.     return result;
  21. }
  22.  
  23. Resistor operator*(int n, const Resistor& r) {
  24.     if ( n <= 0 ) throw "WY9Z2V";
  25.     double result = (n*r.getR());
  26.     Resistor result2(result);
  27.     return result2;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement