Loading...

Във форума е въведено ограничение, което позволява на потребителите единствено да разглеждат публикуваните въпроси.

nsnikolova1 avatar nsnikolova1 3 Точки

task 3 Files

След добавяне в Directory.h на следния код

virtual size_t getSize() const override
    {

    }

дебъгера дава следната грешка

function-style-cast can not convert  from 'const std::shared_ptr <File>' to 'std::shared_ptr'

това което виждам е че грешката касае паметта.

ето условието на здачата

Task 3 – Files

You are given code which reads information File and Directory objects in a file system, each of which has an id, and each of which has a parent – the object which contains it. 

NOTE: For this task, only files will have parents (but similar logic will be used in other tasks in this homework assignment). 

Operations with the files and directories are done with reference to their id, and there are several types of operations:

· file – create a File object with a filename and contents (a sequence of characters, stored in a string)

· directory – create a Directory object with a name

· copy – move a file into a directory, only 1 such operation will be done for any file, and it will always contain a file id to move and a directory id to move to

· size – prints the size in bytes of a File or Directory. The size of a File is equal to the size (number of characters) of its contents. The size of Directory is equal to the sum of the sizes of the File objects in it.

· path – prints the path of a File or Directory. The path is the sequence of parents for the File/Directory, separated by "/", followed by the name of the File/Directory. For this task, only Files will have parents, meaning that paths for a directory will always be just its name.

· print – prints the contents of a File – will only be called with ids of already existing Files

The provided code is missing the definitions for the File and Directory classes – you should implement them. Also, you should study the code and see what inheritance hierarchy is used to represent the file system and implement any other necessary classes/interfaces and functions.

You should submit a single .zip file for this task, containing ONLY the file(s) YOU created. The Judge system has a copy of the other files and will compile them, along with your file, in the same directory.

Restrictions

The input will always contain correct operations – i.e. any object used by an operation will have already been created by the file or directory operations. There will be no invalid ids, no copy or print operations on Directory objects (but the destination of a copy operation will always be a Directory).

The provided code handles input/output and operation management – you should focus on implementing the classes it uses.

Examples

Input

Output

file 1 example.txt some example bytes as text

file 2 otherFile.txt other text

path 1

directory 3 examples

path 3

copy 1 3

path 1

print 1

path 2

end

example.txt

examples

examples/example.txt

some example bytes as text

otherFile.txt

file 1 example.txt some example bytes as text

file 2 otherFile.txt other text

size 1

size 2

directory 3 examples

size 3

copy 1 3

size 3

copy 2 3

size 3

end

26

10

0

26

36

Eто и линк към файловете

Directory.h - https://pastebin.com/Uc9Jd6je

FILESYSTEMOBJECTSCONTAINER.H -https://pastebin.com/D4D5nmq8

FileSystemObject.h -https://pastebin.com/mtUKrPL0

ByteContainer.h -https://pastebin.com/bbY1utCz

File.h - https://pastebin.com/Rb24ttAS

FilesMain.cpp -https://pastebin.com/qtmJNsDT

Тагове:
0
Open Courses
takvor avatar takvor 45 Точки

Ще ти трябват още някои неща:

#include "FileSystemObjectsContainer.h"  плюс private контейнер, който да събира членовете на директорията (напр. list от shared_ptr<FileSystemObject>) - там функцията add ще добавя.

цитираната фукция getSize връща size_t, така че ѝ трябва return

default constructor:     Directory() = default;

0
Можем ли да използваме бисквитки?
Ние използваме бисквитки и подобни технологии, за да предоставим нашите услуги. Можете да се съгласите с всички или част от тях.
Назад
Функционални
Използваме бисквитки и подобни технологии, за да предоставим нашите услуги. Използваме „сесийни“ бисквитки, за да Ви идентифицираме временно. Те се пазят само по време на активната употреба на услугите ни. След излизане от приложението, затваряне на браузъра или мобилното устройство, данните се трият. Използваме бисквитки, за да предоставим опцията „Запомни Ме“, която Ви позволява да използвате нашите услуги без да предоставяте потребителско име и парола. Допълнително е възможно да използваме бисквитки за да съхраняваме различни малки настройки, като избор на езика, позиции на менюта и персонализирано съдържание. Използваме бисквитки и за измерване на маркетинговите ни усилия.
Рекламни
Използваме бисквитки, за да измерваме маркетинг ефективността ни, броене на посещения, както и за проследяването дали дадено електронно писмо е било отворено.