Advertisement
Guest User

Untitled

a guest
Sep 15th, 2019
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.08 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. class Students{
  4. private:
  5.     string name;
  6.     int age;
  7. public:
  8.     Students(string n,int a){
  9.         name = n;
  10.         age = a;
  11.     }
  12.     string gName(){
  13.         return name;
  14.     }
  15.     int gAge(){
  16.         return age;
  17.     }
  18.     void constant1(){
  19.         cout << "The student's name is : ";
  20.     }
  21.     void constantMale(){
  22.         cout << " , and his age is : ";
  23.     }
  24.     void constantFemale(){
  25.         cout << " , and her age is : ";
  26.     }
  27.     void barrier(){
  28.         cout <<"-----------------------------------------------------" << endl;
  29.     }
  30. };
  31. int main()
  32. {
  33.     Students c1("Mohanad",16);
  34.     Students c2("Rada",17);
  35.     Students c3("Syne",18);
  36.     c1.constant1();
  37.     cout << c1.gName();
  38.     c1.constantMale();
  39.     cout << c1.gAge() << endl;
  40.     c1.barrier();
  41.     c2.constant1();
  42.     cout << c2.gName();
  43.     c2.constantFemale();
  44.     cout << c2.gAge() << endl;
  45.     c2.barrier();
  46.     c3.constant1();
  47.     cout << c3.gName();
  48.     c3.constantMale();
  49.     cout << c3.gAge() << endl;
  50.     c3.barrier();
  51.     return 0;
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement