Advertisement
Guest User

new

a guest
Jul 22nd, 2018
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.42 KB | None | 0 0
  1. #include <list>
  2.  
  3.  
  4. template <typename T>
  5. class Vector
  6. {
  7.     T *elem;
  8.     int sz;
  9.  
  10.   public:
  11.     ~Vector() { delete[] elem; }
  12.     Vector(int s);
  13.  
  14.     T& operator[](int s);
  15.     const T &operator[](int s) const;
  16.     int size();
  17. };
  18.  
  19. template <typename T>
  20. Vector<T>::Vector(int s) : elem{new T[s]}, sz{s} {}
  21.  
  22. template <typename T>
  23. const T &Vector<T>::operator[](int s)
  24. const{
  25.     return elem[s];
  26. }
  27.  
  28. int main() {
  29.     Vector <int> one (20);
  30.     Vector <double> two (20);
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement