Advertisement
Josif_tepe

Untitled

Oct 16th, 2021
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.56 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. };
  16. void check_age(student s) {
  17.     if(s.age > 25) {
  18.         cout << "YES " << s.name << " " << s.surname << endl;
  19.     }
  20.     else {
  21.         cout << "NO" << endl;
  22.     }
  23. }
  24. int main() {
  25.     student s("a", "b", 30);
  26.     check_age(s);
  27.     return 0;
  28. }
  29.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement