Hi ,
I need help for creating copy constructor for linked list with structure member.
It compiles correctly but gives runtime error . The problem here is in memory management but I am not able to handle it.Please help me...
"Array(const Array &a,string st)" is not called as you expected. Since only one parameter is put, the call at #144 was not calliing yours, but Array(const Array &a) which is implicitly generated to copy all parameters to the "x" including "p" and all its pointers ( their addresses).
The run time error could happen when their descontructors are called to delete those addresses at the end of the whole app. ( The descontructor is called implicitly during the ending)
By the way, in the copy constructor, just as the normal constructor does, may you need to firstly add one line to declare "p = NULL".