Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #ifndef STATICARRAY_H
- #define STATICARRAY_H
- template <typename T, int CAP>
- class StaticArray
- {
- private:
- T values[CAP];
- T dummy;
- public:
- StaticArray(){
- dummy = T();
- for(int i = int (); i < CAP; i++)
- values [i] = T();
- }
- int capacity()const{
- return CAP;
- //sizeof(values)/sizeof(*values);
- }
- T operator [](int index)const{
- if(index < 0) return dummy;
- if(index > CAP) return dummy;
- return values [index];
- }
- T& operator [] (int index){
- if(index < 0) return dummy;
- if(index >= CAP) return dummy;
- return values [index];
- }
- };
- #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement