Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
C++
Please, help me. It's destructor problem
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="kwangbok.kim, post: 2582237"] Hi. I'm major in computer science. While studying with the what kind of document, the problem got. Please help me. The lower part is the program... Programming with visual c++ 6.0 at windows xp -------------------------------------------------------------------------------------------- #include <iostream.h> #include <string.h> class Date { int d, m, y; public: Date(int dd=5, int mm=5, int yy=2005) : d(dd), m(mm), y(yy) { cout << "Date Object Created .. " << endl; } ~Date() { cout << "Date : " << y << "/" << m << "/" << d << endl; } void print(); }; void Date::print() { cout << "Date : " << y << "/" << m << "/" << d << endl; } class Person { char *name; Date *birthday; public: Person(char *n, Date *d); ~Person() { delete[] name; cout << "Person Object Destructed .. " << endl; } void print(); }; Person::Person(char *n, Date *d) : birthday(d) { name = new char[strlen(n) +1]; strcpy(name,n); cout << "Person Object Created .. " << endl; } void Person::print() { cout << "Name : " << name << endl; cout << "Birthday : "; birthday->print(); cout << endl; } int main(void) { Date day(1,1,1973); Person hong("Hong, Gin-Dong", &day); hong.print(); Person jang = hong; jang.print(); return 0; } [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
C++
Please, help me. It's destructor problem
Top