Skip to content

Instantly share code, notes, and snippets.

@coldcue
Last active December 14, 2015 18:19
Show Gist options
  • Save coldcue/5128476 to your computer and use it in GitHub Desktop.
Save coldcue/5128476 to your computer and use it in GitHub Desktop.
#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