Name change working perfectly

Prateek bhaiya explained that if we change the name that is dynamically assigned it will change the name of the original object as well but this does no happen in my code.

#include
#include
using namespace std;

class Car
{
private:
int price;

public:
int model;
char *name;
Car()
{
name = NULL;
}
Car(float p, int m, char *n)
{
price = p;
model = m;
name = new char[strlen(n) + 1];
strcpy(name, n);
}
void print()
{
cout << "Name : " << name << endl;
cout << “Model :” << model << endl;
cout << “Price :” << price << endl;
}
void set_price(float p)
{
price = p;
}
};

int main()
{
cout << “From car c” << endl;
Car c(1000, 3, “Audi”);
Car d©;

d.name = "AMW";
d.set_price(3000);

c.print();
d.print();
return 0;

}

Hi… pls save ur code on ide and share link

This will not run in the online ide because of warnings.

Please go through the video once again. all ur doubts will be cleared

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.