Error in last for loop

class car{
public:
string name;
int x;
int y;
car(string n,int x, int y)
{
n = name;
this->x=x;
this->y=y;
}
int distance()
{
return xx+yy;
}
};

bool compare(car c1,car c2)
{
int d1=c1.distance();
int d2=c2.distance();
return d1<d2;
}
int main()
{
int n;
cin >> n;
vectorv;
for(int i=0;i<n;i++)
{
string name;
int x,y;
cin >> name >> x >> y;
car c(name,x,y);
v.push_back©;
}
sort(v.begin(),v.end(),compare);
for(auto it : v)
{
cout << it.distance() << endl;
}
return 0;

@Saurabh10 share your code using cb ide

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.