Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <list>
- template <typename T>
- class Vector
- {
- T *elem;
- int sz;
- public:
- ~Vector() { delete[] elem; }
- Vector(int s);
- T& operator[](int s);
- const T &operator[](int s) const;
- int size();
- };
- template <typename T>
- Vector<T>::Vector(int s) : elem{new T[s]}, sz{s} {}
- template <typename T>
- const T &Vector<T>::operator[](int s)
- const{
- return elem[s];
- }
- int main() {
- Vector <int> one (20);
- Vector <double> two (20);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement