Advertisement
Guest User

Untitled

a guest
Aug 25th, 2019
117
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. #include <cstring>
  3. using namespace std;
  4.  
  5. class ContactInfo {
  6. private:
  7.     char* name;
  8.     char* phone;
  9. public:
  10.     ContactInfo(char* n, char* p)
  11.     {
  12.         name = new char[strlen(n) + 1];
  13.         phone = new char[strlen(p) + 1];
  14.  
  15.         int size = strlen(n) + 1;
  16.         strcpy(name, n);
  17.         strcpy(phone, p);
  18.     }
  19.     ~ContactInfo()
  20.     {
  21.         delete[] name;
  22.         delete[] phone;
  23.     }
  24.  
  25.     const char* getName() const
  26.     {
  27.         return name;
  28.     }
  29.     const char* getPhoneNumber() const
  30.     {
  31.         return phone;
  32.     }
  33. };
  34.  
  35.  
  36. int main()
  37. {
  38.     ContactInfo entry("kristin lee", "951-199-9999");
  39.  
  40.  
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement