Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- using namespace std;
- template<typename T>
- class Set
- {
- public:
- class Iterator;
- void add(T v);
- void remove(T v);
- Iterator begin();
- Iterator end();
- private:
- vector<T> data;
- };
- template <class T>
- Set<T> addstuff()
- {
- Set<T> a;
- a.add(1);
- a.add(2);
- a.add(3);
- a.add("a string");
- return a;
- }
- void main()
- {
- addstuff<Set>(); //<< Error here. If I use addstuff<int>(), it would run but
- //I can't add string to it. I am required to be able to add
- //different data types to this vector
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement