Advertisement
Elygian

Bluejay

Dec 1st, 2015
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.77 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3.  
  4. using namespace std;
  5.  
  6. class Person
  7. {
  8.  
  9. protected:
  10.   string m_FirstName, m_LastName, m_email;
  11.  
  12. public:
  13.   Person(){}
  14.   Person(const string& firstName, const string& lastName) :
  15.     m_FirstName(firstName), m_LastName(lastName)
  16.        {}
  17.  
  18.         string get_name() const
  19.         {
  20.                 return m_FirstName;
  21.         }
  22.         string get_surname() const
  23.         {
  24.                 return m_LastName;
  25.         }
  26.  
  27.        
  28.  
  29.         bool has_email_p()
  30.         {
  31.        
  32.         }
  33. };
  34.  
  35. class Person_with_telephone: public Person
  36. {
  37.  
  38. protected:
  39.   string m_telephone;
  40.  
  41. public:
  42.   Person_with_telephone(){}
  43.   Person_with_telephone(const string& telephone) : m_telephone(telephone)
  44.   {}
  45.  
  46.    bool has_telephone_p()
  47.         {
  48.                 if (m_telephone == "")
  49.                 {
  50.                   cout  << "You have no phone number registered" << endl;
  51.           return false;
  52.                 }
  53.                
  54.                 else
  55.                 {
  56.                   cout  << "Your number is: " << m_telephone << endl;
  57.           return true;
  58.                 }
  59.         }
  60.  
  61.        string get_telephone() const
  62.         {
  63.                  return m_telephone;
  64.         }
  65.  
  66.   string set_telephone()
  67.   {
  68.  
  69.   }
  70.  
  71.   string get_telephone()
  72.   {
  73.  
  74.   }
  75.    
  76.  
  77. };
  78.  
  79. int main()
  80. {
  81.   string f, l, ph;
  82.  
  83.         cout << "Enter fist name: ";
  84.         cin >> f;
  85.         cout << "Enter Last name: ";
  86.         cin >> l;
  87.     cout << "Enter telephone number: ";
  88.     cin >> ph;
  89.         Person p(f, l);
  90.     Person_with_telephone pwt(ph);
  91.         cout << "Your name is: " << p.get_name() << " " << p.get_surname() << endl;
  92.     cout << "Has telephone? " << endl << " Your number is: " << pwt.get_telephone() << endl;
  93.  
  94.         return 0;
  95. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement