SHARE
TWEET

Untitled

a guest Dec 11th, 2019 95 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2.  
  3. template <class A>
  4. class Array
  5. {
  6. public:
  7.     Array() : size_(0), data_("") {}
  8.     Array(size_t size) : size_(size), data_(new A[size]) {}
  9.     ~Array() { delete[] data_; };
  10.     size_t size() const { return size_; }
  11.     A& operator[] (size_t i) const
  12.     {
  13.         if (i >= size_)
  14.             throw std::out_of_range("index out of border");
  15.         return data_[i];
  16.     }
  17. private:
  18.     size_t size_;
  19.     A* data_;
  20. };
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top