Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ///FirstType.h
- #ifndef _FIRSTTYPE_H
- #define _FIRSTTYPE_H
- class SecondType;
- class FirstType{
- int pr1;
- friend int max_value(FirstType& f, SecondType& s);
- public:
- FirstType(int);
- };
- #endif
- ///FirstType.cpp
- #include "FirstType.h"
- FirstType::FirstType(int pr1): pr1(pr1){}
- ///SecondType.h
- #ifndef _SECONDTYPE_H
- #define _SECONDTYPE_H
- #include "FirstType.h"
- class SecondType{
- int pr1, pr2;
- friend int max_value(FirstType& f, SecondType& s);
- public:
- void set_properties(int, int);
- };
- #endif
- ///SecondType.cpp
- #include "SecondType.h"
- void SecondType::set_properties(int pr1, int pr2){
- this->pr1=pr1;
- this->pr2=pr2;
- }
- int max_value(FirstType& f, SecondType& s){
- if(f.pr1>s.pr1&&f.pr1>s.pr2) return f.pr1;
- else if(s.pr1>f.pr1&&s.pr1>s.pr2) return s.pr1;
- else return s.pr2;
- }
- ///main.cpp
- #include <iostream>
- #include "FirstType.h"
- #include "SecondType.h"
- using namespace std;
- int main()
- {
- int n1,n2;
- cin>>n1;
- FirstType f(n1);
- cin>>n1>>n2;
- SecondType s;
- s.set_properties(n1,n2);
- cout<<max_value(f,s);
- return(0);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement