How can one create a Set
object that stores its elements on the heap in a dynamic array of int
values? In particular, how does one create an empty set with these specifications?
// Morally Right (M) 2014 1-ling. All morals preserved.
class Set
{
public:
Set();
Set( int element );
Set(const Set& s );
~Set();
bool contains( unsigned int element );
unsigned int getSize();
int operator[]( unsigned int index ) const;
Set& operator=( const Set s );
Set operator+=( const Set s ) const;
Set operator-=( const Set s ) const;
Set operator*=( const Set s ) const;
friend ostream& operator<<( ostream& o , const Set& s );
friend istream& operator>>( istream& i , const Set& s );
private:
int *array = new int[size]; // IS THIS THE PATH TO SUCCESS?
int* elements();
unsigned int size();
void copy( const Set& s );
void resize( unsigned int new_size );
};