fork download
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4.  
  5. class PERSON
  6. {
  7. private:
  8. string Pib;
  9. string sex;
  10. int bDay[3];
  11. public:
  12.  
  13. // Constructors
  14. PERSON();
  15. PERSON(string name);
  16. PERSON(string name, string sex);
  17. PERSON(string name, string sex, int* bday);
  18. PERSON(const PERSON& other);
  19. ~PERSON();
  20. // Input and Output
  21. PERSON input();
  22. void printPerson(PERSON& data);
  23.  
  24. };
  25.  
  26. PERSON::PERSON() {
  27. cout << "Created object without arguments!" << this << endl;
  28. Pib = sex = "";
  29. for (int i = 0; i < 3; i++) {
  30. bDay[i] = 0;
  31. }
  32. }
  33.  
  34. PERSON::PERSON(string name) {
  35. this->Pib = name;
  36. }
  37.  
  38. PERSON::PERSON(string name, string sex) : PERSON(name) {
  39. this->sex = sex;
  40. }
  41.  
  42. PERSON::PERSON(string name, string sex, int* bday) : PERSON(name, sex){
  43. cout << "You created a full Person!" << this << endl;
  44. for (int i = 0; i < 3; i++) {
  45. this->bDay[i] = bday[i];
  46. }
  47. }
  48.  
  49. PERSON::PERSON(const PERSON& other) {
  50. cout << "Copy constructor!" << this << endl;
  51. this->Pib = other.Pib;
  52. this->sex = other.sex;
  53. for (int i = 0; i < 3; i++) {
  54. this->bDay[i] = other.bDay[i];
  55. }
  56. }
  57.  
  58. PERSON::~PERSON() {
  59. cout << "Person deleted" << this << endl;
  60. }
  61.  
  62.  
  63. int main()
  64. {
  65. int nPerson;
  66. cout << "How much Human you watn to created" << endl;
  67. cin >> nPerson;
  68. PERSON* human = new PERSON[nPerson];
  69. string name = "Volodia";
  70. string sex = "Man";
  71. //PERSON tmp(name, sex, { 28, 07, 2003 });
  72.  
  73. int tmp_array[] = { 28, 07, 2003 };
  74. PERSON tmp(name, sex, tmp_array);
  75.  
  76. for (int i = 0; i < nPerson; i++) {
  77. tmp.printPerson(human[i]);
  78. }
  79. }
  80.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
/usr/bin/ld: /home/Nkg537/ccCNS9NY.o: in function `main':
prog.cpp:(.text.startup+0x1a7): undefined reference to `PERSON::printPerson(PERSON&)'
collect2: error: ld returned 1 exit status
stdout
Standard output is empty