I have two classes FilySystemFolder and Folder.Folder is inherited from FilySystemFolder.Folder has array of pointers to FileSystemFolder.FileSystemFolder
has a poiter to Folder(*Folder).In folder there is a function that puts an item to an FilySystemArray.If you put folder a in folder b,b becomes its parent folder.Now you have to make name of the folder like concatenation of all it's parents folders.Here is my code:
#pragma once
#include<string>
class Folder;
class FileSystemElement
{protected:
char *ime;//name
char *ekstenzija;//ekstension
Folder *p;//pointer to parent folder
public:
FileSystemElement() :p(nullptr), ime(nullptr), ekstenzija(nullptr){}
FileSystemElement(constchar * ime,constchar *ekstenzija);
//I made teo constructors
void Set_folder(Folder f);// makes p points to another folder
Folder* PripadaFolder() { return p; }
void Rekurzija();//This prototype of function for some recursion
virtual ~FileSystemElement();
virtualchar * Vrati() = 0;
virtualvoid PrintList() = 0;
//virtual functions defined in Folder.h
};
#include"Folder.h"
#pragma once
#include<iostream>
#include"FileSystemElement.h"
class FileSystemElement;
usingnamespace std;
class Folder:public FileSystemElement
{
private:
FileSystemElement **m;
public:
Folder() :FileSystemElement(nullptr, "")
//ekstenzija(ekstension) is empty string in Folder
{
m = new FileSystemElement*[2018];//array has to have 2018 spaces
for (int i = 0; i < 2018; i++)
m[i] = nullptr;
}
void ImeFolderu(char * name);
//Set name of the folder like concatenation of name and all parents names
virtual ~Folder();
virtualchar* Vrati();//return name of Folder
virtualvoid PrintList();//will be defined later
void Dodaj(Folder *f);//Put folder in array
void Ukloni(int i);//remove folder form an array
Folder& operator=(const Folder &f);