Advertisement
High_Light

Classes 2

Feb 27th, 2018
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.55 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3.  
  4. using namespace std;
  5.  
  6. class Human {
  7. public:
  8.     string name;
  9.     string surname;
  10.     int age;
  11.     Human (string a, string b){
  12.         name = a;
  13.         surname= b;
  14.  
  15.     }
  16.     void Hello(){
  17.         cout << "Hello my name is "<<name << " "<< surname<< endl;
  18.     }
  19.     Human (int x){
  20.         age=x;
  21.     }
  22.     void Years(){
  23.         cout << age <<"years old"<< endl;
  24.     }
  25.  
  26. };
  27.  
  28. int main()
  29. {
  30.   Human a= Human("Sergey","Trukhachev");
  31.   a.Hello();
  32.   Human b= Human(18);
  33.   b.Years();
  34.     return 0;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement