Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstring>
- using namespace std;
- class FSObject
- {
- private:
- char* name;
- public:
- FSObject(const char* newName): name(NULL)
- {
- setName(newName);
- }
- FSObject(const FSObject& other): name(NULL)
- {
- setName(other.name);
- }
- FSObject& operator=(const FSObject& other)
- {
- if(this != &other)
- {
- setName(other.name);
- }
- return *this;
- }
- virtual ~FSObject()
- {
- delete[] name;
- }
- virtual double getSize() const=0;
- const char* getName() const
- {
- return name;
- }
- void setName(const char* newName)
- {
- delete[] name;
- name = new char[strlen(newName) + 1];
- strcpy_s(name, strlen(newName) + 1, newName);
- }
- };
- class Directory: public FSObject
- {
- private:
- FSObject** objects;
- size_t count;
- size_t capacity;
- void copy(const Directory& other)
- {
- capacity = other.capacity;
- count = other.count;
- objects = new FSObject*[capacity];
- for(size_t i = 0; i < count; ++i)
- {
- objects[i] = other.objects[i];
- }
- }
- void free();
- public:
- Directory(const char* newName): FSObject(newName), count(0), capacity(1)
- {
- objects = new FSObject*[capacity];
- for(size_t i = 0; i < capacity; i++)
- {
- objects[i] = NULL;
- }
- }
- Directory(const Directory& other): FSObject(other)
- {
- copy(other);
- }
- Directory& operator=(const Directory& other)
- {}
- ~Directory()
- {
- }
- void addFSObject(const FSObject& toADD)
- {
- }
- void deleteFSObject(const FSObject& toDEL)
- {
- }
- virtual double getSize() const
- {
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement