Advertisement
selebry

fefeasdadsa

Mar 4th, 2022
1,360
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.06 KB | None | 0 0
  1. ///FirstType.h
  2. #ifndef _FIRSTTYPE_H
  3. #define _FIRSTTYPE_H
  4.  
  5. class SecondType;
  6. class FirstType{
  7.     int pr1;
  8.     friend int max_value(FirstType& f, SecondType& s);
  9.     public:
  10.     FirstType(int);
  11. };
  12.  
  13. #endif
  14. ///FirstType.cpp
  15. #include "FirstType.h"
  16. FirstType::FirstType(int pr1): pr1(pr1){}
  17.  
  18. ///SecondType.h
  19. #ifndef _SECONDTYPE_H
  20. #define _SECONDTYPE_H
  21. #include "FirstType.h"
  22.  
  23. class SecondType{
  24.     int pr1, pr2;
  25.     friend int max_value(FirstType& f, SecondType& s);
  26.     public:
  27.     void set_properties(int, int);
  28. };
  29.  
  30. #endif
  31.  
  32. ///SecondType.cpp
  33. #include "SecondType.h"
  34. void SecondType::set_properties(int pr1, int pr2){
  35.     this->pr1=pr1;
  36.     this->pr2=pr2;
  37. }
  38. int max_value(FirstType& f, SecondType& s){
  39.     if(f.pr1>s.pr1&&f.pr1>s.pr2) return f.pr1;
  40.     else if(s.pr1>f.pr1&&s.pr1>s.pr2) return s.pr1;
  41.     else return s.pr2;
  42. }
  43.  
  44. ///main.cpp
  45. #include <iostream>
  46. #include "FirstType.h"
  47. #include "SecondType.h"
  48. using namespace std;
  49. int main()
  50. {
  51.     int n1,n2;
  52.     cin>>n1;
  53.     FirstType f(n1);
  54.     cin>>n1>>n2;
  55.     SecondType s;
  56.     s.set_properties(n1,n2);
  57.     cout<<max_value(f,s);
  58.     return(0);
  59. }
  60.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement