Hello, I have a problem with this code that is supposed to behave "like a STL set". It's part of a school assignment. When I'm saving integers or strings, it works. But when I try to save an class with a private default constructor (the school testing system uses this to validate if the points in the assignment are being kept, classes being saved to the "set" have guaranteed working copy constructor, operator < for comparing and operator = for assigning). Is there a way to save the class without calling the default constructor or is this whole code just incorrect? Any kind of help will be much appreciated.
The thing is that I don't know what will be supplied as T. Type that is passed to the functions is described only as:
Class Type, template parameter, guarantees the following functionality:
• copy constructor,
• copy assignment operator,
• operator< for comparing two elements.
struct Node
{
T m_Data{}; // need to save class with a private constructor
Node *m_Next{};
Node(const T& md) : m_data(md) {}
};
...
Node *newNode = new Node(in);
Note that for Insert(), Remove() and Contains, T should be passed by const ref and not by value.