Advertisement
Guest User

Untitled

a guest
Jun 24th, 2019
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. #include "iostream"
  2. #include "string"
  3.  
  4. class Phonebook {
  5. private:
  6. char* name;
  7. long long home_phone;
  8. long long work_phone;
  9. long long mob_phone;
  10. char dop_info[64];
  11. public:
  12. Phonebook() = default;
  13.  
  14. void set_abonent(char* namex, long long home_phonex, long long work_phonex, long long mob_phonex, char dop_infox[64]) {
  15. int size = 0;
  16. while (namex[size] != '\0') {
  17. size++;
  18. }
  19.  
  20. name = new char[size];
  21. strcpy_s(name, size, namex);
  22. home_phone = home_phonex;
  23. work_phone = work_phonex;
  24. mob_phone = mob_phonex;
  25. strcpy_s(dop_info, dop_infox);
  26.  
  27. }
  28.  
  29. ~Phonebook() {
  30. delete[] name;
  31. }
  32.  
  33. void print() {
  34. std::cout << "Name " << name << std::endl;
  35. std::cout << "Home phone " << home_phone << std::endl;
  36. std::cout << "Work phone" << work_phone << std::endl;
  37. std::cout << "Mobile phone " << mob_phone << std::endl;
  38. std::cout << "Other info " << dop_info << std::endl;
  39.  
  40. }
  41.  
  42.  
  43. };
  44.  
  45.  
  46.  
  47. int main() {
  48.  
  49. char name[128];
  50. long long home_phone;
  51. long long work_phone;
  52. long long mob_phone;
  53. char dop_info[64];
  54.  
  55. Phonebook* abonent = new Phonebook[3];
  56.  
  57.  
  58.  
  59. /*char ttt[64];
  60. std::cin.getline(ttt,64);
  61.  
  62. std::cout << ttt;*/
  63.  
  64.  
  65. return 0;
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement