Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #ifndef Set_hpp
- #define Set_hpp
- template <class T>
- class MultiSet{
- public:
- MultiSet(){};
- virtual void add(T param){};
- bool test(T param){};
- virtual void remove (T param){};
- };
- template <class T>
- class Set : public MultiSet<T>
- {
- public:
- Set(){};
- void add(T t);
- void remove (T t);
- };
- template <class T>
- class duplicateException{
- public:
- T value;
- duplicateException(T v){value = v;};
- };
- template <class T>
- class removeException{
- public:
- T value;
- removeException(T v){value = v;};
- };
- template <class T> void Set<T>::add(T t){
- if (this->test(t))
- throw new duplicateException<T>(t);
- else
- MultiSet<T>::add(t);
- }
- template <class T> void Set<T>::remove(T t){
- if (!this->test(t))
- throw new removeException<T>(t);
- else
- MultiSet<T>::remove(t);
- }
- #endif // Set_hpp
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement