I have created a set of points(user defined) by overriding < operator. I'm unable to print the set elements.Thanks in advance.
here's the program
#include<bits/stdc++.h>
using namespace std;
class point
{
double x,y;
public:
point(double x=0,double y=0):x(x),y(y){}
bool operator <(point &p)const
{
if(x!=p.x && y!=p.y)
return true;
return false;
}
friend void show(set<point> &s);
};
void show(set<point> &s)
{
for(auto xx=s.begin();xx!=s.end();xx++)
cout<<(*xx).x<<" "<<(*xx).y<<endl;
}
int main()
{
set<point> s;
for(int x=0;x<10;x++)
s.insert(x,x);
show(s);
return 0;
}
Aucun commentaire:
Enregistrer un commentaire