#ifndef _SET_H_
#define _SET_H__
/* - - - - - - - - - - - - - - - - - - - - - - - - - - */
class set : public bag {
private:
protected:
public:
set();
~set();
void add(entity * ENT); // add ENT into set if not there
void add(char * NAME); // add entity with given name to set
set * union_objects(container * c); //return the union as a new set
void union_self(container * c); //unite with c
set * intersect_objects(container * c); //return the intersections as
a new set void intersect_self(container * c); //intersect with c
set * container_to_set(container * c);
set * bag_to_set(bag * b);
};
#endif
Class bag inherits function add(...) from class container, and set inherits function add(...) from class bag, after modifying it to guard against addition of second occurrences:
void set::add(entity * ent) // add ent into set
{
if (!is_in(ent)) // if it is not already in set,
container::add(ent);
}