Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "resistor.h"
- double Resistor::defR = 163.0;
- Resistor::Resistor(){ R = defR; }
- Resistor::Resistor(double r) { R = r; }
- void Resistor::setDef(double b = 163.0) { defR = b; }
- Resistor Resistor::operator+(const Resistor& r) const {
- Resistor result(*this);
- result.R+=r.R;
- return result;
- }
- Resistor Resistor::operator%(const Resistor& r) const {
- Resistor result;
- result.R=1/((1/this->R)+(1/r.R));
- return result;
- }
- Resistor operator*(int n, const Resistor& r) {
- if ( n <= 0 ) throw "WY9Z2V";
- double result = (n*r.getR());
- Resistor result2(result);
- return result2;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement