fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. class Number
  5. {
  6. int num;
  7. public:
  8. Number()
  9. {
  10. cout<<"Enter number: ";
  11. cin>>num;
  12. }
  13. void display()
  14. {
  15. cout<<num<<' ';
  16. }
  17. friend void Greatest(Number&, Number&,Number&);
  18. };
  19.  
  20. void Greatest(Number& obj1,Number& obj2,Number& obj3)
  21. {
  22. cout<<"\nGreatest number is: ";
  23. cout<<max(obj1.num,max(obj2.num,obj3.num));
  24. }
  25.  
  26. int main()
  27. {
  28. Number obj1,obj2,obj3;
  29. Greatest(obj1,obj2,obj3);
  30.  
  31. return 0;
  32. }
  33.  
Success #stdin #stdout 0.01s 5288KB
stdin
Standard input is empty
stdout
Enter number: Enter number: Enter number: 
Greatest number is: 21956