Witam, Czy jest ktoś w stanie mi pomóc z tym zadaniam, nie rozumiem zupełnie o co w nim chodzi. Może ma ktoś jakiś przykład bardzo podobny bym go zrozumiał i zrobił to zadanie ?
0
2
Ale czego nie rozumiesz w tym zadaniu? Musisz napisać generyczną klasę set
z jakimiś tam metodami w środku...
4
Proszę, szablon pod twoje szablonowe zadanie :>
template<typename T>
class Set{
private:
using self_type = Set<T>;
using value_type = T;
// your code goes here
public:
Set() = default;
void insert(const value_type &val){
// your code goes here
}
Set &operator<<(const value_type &val){
insert(val);
return *this;
}
void insert(const self_type &other_set){
// your code goes here
}
Set &operator<<(const self_type &other_set){
insert(other_set);
return *this;
}
auto begin(){
// your code goes here
}
auto begin() const{
// your code goes here
}
auto cbegin() const{
return begin();
}
auto end(){
// your code goes here
}
auto end() const{
// your code goes here
}
auto cend() const{
return end();
}
};
template <class RandomAccessIterator>
void sort(RandomAccessIterator first, RandomAccessIterator last){
// your code goes here
}
template <class RandomAccessIterator, class Compare>
void sort(RandomAccessIterator first, RandomAccessIterator last, Compare comp){
// your code goes here
}
int main(){
// your code goes here
return 0;
}