I am learning C++ and stuck with one scenario where I have to convert array to set
I have pointer which holds the address of array and I want to get all unique elements of array into set . Using STL how its possible . Below is my code spinet and am also looking for good explanation .
#include<set>
void possiblepermutation(int *array) {
set<int> roots(begin(array),end(array));
}
After reading below comment , I understood that as I am passing pointer so begin() and end() will have no idea about start and end . Can you help me what if I pass size of array along with array pointer , how to do.
void possiblepermutation(int *array , int n) {
set<int> roots(begin(array),end(array)); // HOW TO THEN
}