Advertisement
Guest User

Untitled

a guest
Dec 14th, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. #include <iostream>
  2.  
  3.  
  4. class CelsiusDeg {
  5.  
  6. double value;
  7.  
  8. public:
  9. CelsiusDeg() {
  10. value = 10;
  11. }
  12.  
  13. CelsiusDeg(double value) {
  14. this->value = value;
  15. }
  16.  
  17. double operator +(const CelsiusDeg & c) {
  18. return double(this->value + c.value);
  19. }
  20. };
  21.  
  22. class Kelvin {
  23.  
  24. double value;
  25.  
  26. public:
  27. Kelvin() {
  28. value = -273;
  29. }
  30.  
  31. Kelvin(double value) {
  32. this->value = value;
  33. }
  34.  
  35. };
  36.  
  37.  
  38.  
  39. int main() {
  40. CelsiusDeg celciusDeg1;
  41. CelsiusDeg celciusDeg2(37);
  42. Kelvin kelvin1;
  43. Kelvin kelvin2(10);
  44.  
  45. double sum = celciusDeg1 + celciusDeg2;
  46.  
  47. std::cout << sum << std::endl;
  48.  
  49.  
  50.  
  51.  
  52.  
  53. system("pause");
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement