Advertisement
Guest User

Untitled

a guest
Feb 26th, 2017
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. /**
  2. * Ohmikus ellenállást megvalósitó osztály megvalósítása
  3. */
  4.  
  5. /*Itt kell megvalósítani a resistor.h-ban deklarált
  6. nem inline függvényeket.
  7. A Jportára ezt a fajlt kell feltölteni.*/
  8. #include <iostream>
  9. #include "resistor.h"
  10.  
  11. double Resistor::defR=30;
  12.  
  13. Resistor::Resistor(){
  14. R=defR;}
  15.  
  16. Resistor::Resistor(double r){
  17. R=r;
  18. }
  19.  
  20. Resistor operator*(int n, const Resistor& r){
  21. return n*r.getR();}
  22.  
  23.  
  24. Resistor Resistor::operator+(const Resistor& r)const{
  25. return Resistor(R+r.R);
  26. }
  27.  
  28. /*Resistor operator%(const Resistor& r) const{
  29. return Resistor((R*r.R)std::%(R+r.R));
  30. }*/
  31.  
  32. Resistor Resistor::operator%(const Resistor& r) const{
  33. return 1/(1/R + 1/r.getR);
  34. }
  35.  
  36. void Resistor::setDef(double r){
  37. defR=r;
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement