#include using namespace std; class B; class A { int x; public: void setData(int n) { x = n; } friend void findMax(A, B); friend void swapValues(A &, B &); friend void show(A, B); }; class B { int y; public: void setData(int n) { y = n; } friend void findMax(A, B); friend void swapValues(A &, B &); friend void show(A, B); }; void findMax(A a, B b) { if (a.x > b.y) cout << "Maximum is " << a.x << endl; else cout << "Maximum is " << b.y << endl; } void swapValues(A &a, B &b) { int temp = a.x; a.x = b.y; b.y = temp; } void show(A a, B b) { cout << "A = " << a.x << ", B = " << b.y << endl; } int main() { A a; B b; int n1, n2; cout << "Enter value for class A: "; cin >> n1; cout << "Enter value for class B: "; cin >> n2; a.setData(n1); b.setData(n2); show(a, b); findMax(a, b); swapValues(a, b); cout << "After swapping: "; show(a, b); return 0; }