c++ object array help

Ok i am currenly in a c++ programming class and I have not programmed in c++ for a few years now and i cant seem to figure something out. My current project is to create a program that acts like a directory structure, but instead of creating files and directories to the hard drive, it is basically just doing it in the console. Here is what my main method is suppose to look like. My problem is i am suppose to have two arrays in the directory class, one for file class objects and one for directory class objects. Also i will have two methods which are the addFile method and addDir method. My question is how would i go about adding a file object to a directory and also adding a directory object to a directory to. So basically i am not quite sure on how to add for instance the file class objects one and two to an array, or even how to create an array that would take a class object. Any help would be greatly appreciated.

void main ()
{
File one(“one”,5438,”1/8/2008”, “1/8/2008”, “1/8/2008”, 0);
File two(“two”,???????);//??? Add other fields
Directory a(“a”,??????);
Directory b(“a”, ??????);
a.addFile(one);
a.addFile(two);
a.addDir(b);
File* three = new File(“three”, “??????”);
b.addFile(*three);
b.display();
a.display();
one.display();
two.display();
a.removeFile(“one”); //file is removed only from the directory
one.display(); //This will still work.
b.addFile(a.copy());
b.display();
Directory c = a.copy(); //copy the directory
c.display();
}
Last edited on
Topic archived. No new replies allowed.