Container constructors & destructors

C++ Reference

Container constructors & destructors
Syntax:
  #include <set>
  container();
  container( const container& c );
  ~container();

Every set has a default constructor, copy constructor, and destructor.

The default constructor takes no arguments, creates a new instance of that set, and runs in constant time. The default copy constructor runs in linear time and can be used to create a new set that is a copy of the given set c.

The default destructor is called when the set should be destroyed.

For example, the following code creates a pointer to a vector of integers and then uses the default set constructor to allocate a memory for a new vector:

 vector<int>* v;
 v = new vector<int>();           
Related topics: