Advertisement
Josif_tepe

Untitled

Oct 16th, 2021
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.84 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4. class student {
  5. private:
  6.     string name, surname;
  7.     int age;
  8. public:
  9.     student(string _name = "", string _surname = "", int _age = 0) {
  10.         name = _name;
  11.         surname = _surname;
  12.         age = _age;
  13.     }
  14.     friend void check_age(student S);
  15.     friend class CS;
  16.    
  17. };
  18. void check_age(student s) {
  19.     if(s.age > 25) {
  20.         cout << "YES " << s.name << " " << s.surname << endl;
  21.     }
  22.     else {
  23.         cout << "NO" << endl;
  24.     }
  25. }
  26. class CS {
  27. private:
  28.     int x, y;
  29. public:
  30.     CS(int _x, int _y) {
  31.         x = _x;
  32.         y = _y;
  33.     }
  34.     void print(student s) {
  35.         cout << s.name << " " << s.surname << " " <<s.age << endl;
  36.         cout << x << " " << y << endl;
  37.     }
  38. };
  39. int main() {
  40.     student s("a", "b", 30);
  41.     CS c(5, 5);
  42.     c.print(s);
  43. }
  44.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement