Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * File: Array.h
- * Author: rmib
- *
- * Created on 22 Сентябрь 2011 г., 15:56
- */
- #ifndef ARRAY_H
- #define ARRAY_H
- #include <cstddef>
- #include <iostream>
- const int D = 2;
- class Object {
- public:
- typedef int Type;
- Object();
- virtual ~Object();
- friend std::ostream& operator<< (std::ostream&, const Object&);
- friend std::istream& operator>> (std::istream&, Object&);
- virtual const Object::Type& GetValue() const;
- virtual void SetValue(const Object::Type& v);
- virtual Object* Copy() const;
- protected:
- virtual void out( std::ostream& out) const;
- virtual void in( std::istream& in);
- Object::Type id;
- };
- class PDouble: public Object {
- public:
- typedef double Type;
- PDouble();
- virtual const PDouble::Type& GetValue() const;
- virtual void SetValue(const PDouble::Type& v);
- virtual Object* Copy() const;
- protected:
- virtual void out( std::ostream& out) const;
- virtual void in( std::istream& in);
- double value;
- };
- class PInt: public Object {
- public:
- typedef int Type;
- PInt();
- virtual const PInt::Type& GetValue() const;
- virtual void SetValue(const PInt::Type& v);
- virtual Object* Copy() const;
- protected:
- virtual void out( std::ostream& out) const;
- virtual void in( std::istream& in);
- int value;
- };
- class Array {
- Object **v;
- size_t _size;
- size_t _maxSize;
- void newAlloc(size_t sz);
- public:
- Array();
- Array(const Array& orig);
- ~Array();
- size_t Size() const;
- size_t MaxSize() const;
- void Resize(size_t sz, const Object *e);
- bool Empty() const;
- Object *&operator [](size_t n);
- const Object *operator [](size_t n) const;
- Object *&Front();
- const Object *Front() const;
- Object *&Back();
- const Object *Back() const;
- void Assign(size_t n, const Object* e);
- void PushBack(const Object* e);
- void PopBack();
- void Insert(size_t pos, size_t n, const Object* e);
- void Erase(size_t ind);
- void Clear();
- };
- #endif /* ARRAY_H */
Add Comment
Please, Sign In to add comment