#include <iostream>

#include <cstring>

using namespace std;


class Person

{

private:

char * name;

int age;


public:

Person(char * myname, int myage)

{

int len = strlen(myname) + 1;

name = new char[len];

strcpy_s(name, len, myname);

age = myage;

}

void ShowPersonInfo() const

{

cout << "이름: " << name << endl;

cout << "나이: " << age << endl;

}

~Person()

{

delete []name;

cout << "Called destructor!" << endl;

}

};


int main()

{

Person man1("hehehe", 24);

Person man2(man1);

man1.ShowPersonInfo();

man2.ShowPersonInfo();

return 0;


}



여기서 소멸자 부분에서 자꾸 문제가 생기는데요

소멸자를 위에처럼 선언하면 컴파일은 되는데 shallowcopyerror라면서 경고창이 뜨는데 초보라 도무지 모르겠네요

윤성우 책 예제 그대로 한거에 함수만 strcpy에서 strcpy_s로 바꿔준것 뿐인데