#include<iostream>
#include<list>
#include<set>
#include<vector>
#include<climits>
using namespace std;
class DS{
vector<pair<int,int>> *l;
public:
DS(int n){
l = new vector<pair<int, int>>;
}
create_disjointSubset(int n){
for(int i=0;i<n;i++){
l->push_back({i,NULL});
}
}
int find(int curr){
if(l[curr].second == NULL){
return curr;
}
return 0;
}
};
That's the code. I am just trying to create a class called DS (disjoint subsets), and I am also trying to create a vector of pairs to store two integer values. I am new to c++ and I don't know for sure what may be wrong with the code. The error, by the way, is in the function find, for some reason I cannot use l[curr].second or even l[curr].first. I would appreacite any hints or answers