Advertisement
Guest User

Untitled

a guest
May 31st, 2016
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.56 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstring>
  3. using namespace std;
  4.  
  5. class FSObject
  6. {
  7. private:
  8. char* name;
  9. public:
  10. FSObject(const char* newName): name(NULL)
  11. {
  12. setName(newName);
  13. }
  14.  
  15. FSObject(const FSObject& other): name(NULL)
  16. {
  17. setName(other.name);
  18. }
  19.  
  20. FSObject& operator=(const FSObject& other)
  21. {
  22. if(this != &other)
  23. {
  24. setName(other.name);
  25. }
  26. return *this;
  27. }
  28.  
  29. virtual ~FSObject()
  30. {
  31. delete[] name;
  32. }
  33.  
  34. virtual double getSize() const=0;
  35.  
  36. const char* getName() const
  37. {
  38. return name;
  39. }
  40.  
  41. void setName(const char* newName)
  42. {
  43. delete[] name;
  44. name = new char[strlen(newName) + 1];
  45. strcpy_s(name, strlen(newName) + 1, newName);
  46. }
  47.  
  48. };
  49.  
  50. class Directory: public FSObject
  51. {
  52. private:
  53. FSObject** objects;
  54. size_t count;
  55. size_t capacity;
  56.  
  57. void copy(const Directory& other)
  58. {
  59. capacity = other.capacity;
  60. count = other.count;
  61. objects = new FSObject*[capacity];
  62. for(size_t i = 0; i < count; ++i)
  63. {
  64. objects[i] = other.objects[i];
  65. }
  66. }
  67. void free();
  68. public:
  69. Directory(const char* newName): FSObject(newName), count(0), capacity(1)
  70. {
  71. objects = new FSObject*[capacity];
  72. for(size_t i = 0; i < capacity; i++)
  73. {
  74. objects[i] = NULL;
  75. }
  76. }
  77.  
  78. Directory(const Directory& other): FSObject(other)
  79. {
  80. copy(other);
  81. }
  82.  
  83. Directory& operator=(const Directory& other)
  84. {}
  85.  
  86. ~Directory()
  87. {
  88. }
  89.  
  90. void addFSObject(const FSObject& toADD)
  91. {
  92.  
  93. }
  94.  
  95. void deleteFSObject(const FSObject& toDEL)
  96. {
  97.  
  98. }
  99.  
  100. virtual double getSize() const
  101. {
  102.  
  103. }
  104.  
  105.  
  106. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement