Last active
December 14, 2015 18:19
-
-
Save coldcue/5128476 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "resistor.h" | |
double Resistor::defR = 1290; | |
Resistor::Resistor() : R(defR) {} | |
Resistor::Resistor(double r) : R(r) {} | |
void Resistor::setDef(double r) { | |
Resistor::defR = r; | |
} | |
Resistor Resistor::operator+(const Resistor& r) const { | |
return Resistor(R+r.R); | |
} | |
Resistor Resistor::operator%(const Resistor& r) const { | |
return Resistor(1/(1/R+1/r.R)); | |
} | |
Resistor operator*(int n, const Resistor& r) { | |
if(n <= 0) throw "DP1FGW"; | |
return Resistor(n*r.getR()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment