Advertisement
andruhovski

SP0203c

Nov 1st, 2012
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.37 KB | None | 0 0
  1. template <typename Type>
  2. Type max2 (Type x, Type y) { return (x<y)?y:x;};
  3.  
  4. template <typename T,int n> class Array {
  5.     T *a;
  6.     int size;
  7. public:
  8.     Array() {a=new T[n]; size=n;};
  9.     void show() {
  10.         for (int i=0;i<size; i++) std::cout << a[i] <<std::endl;
  11.     }
  12.     bool set(T val,int index)
  13.     {
  14.         if ((index<0)||(index>=size))   return false;
  15.         a[index]=val;
  16.         return true;
  17.     }
  18. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement