hi @vishaaltiwari1999
shallow copy created when default copy constructor is called
but you have make your ones so it is not calling default constructor
and in your copy constructor you make a mistake so it is giving segmentation fault
to get correct output
- first remove your copy constructor (line 19-24)
then see ouput boths name will change
now add your own copy constructor with some change
modified copy constructor
car (const car &x)
{
int l=strlen(x.name)+1;
name = new char[l];
strcpy(name,x.name);
price=x.price;
model=x.model;
}
after that deep copy will be created
i hope this help
if you have more doubts regarding this feel free to ask
if your doubt is resolved mark it as resolved from your doubt section inside your course
Modified Code