Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9309303
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 19, 20262026-06-19T00:50:04+00:00 2026-06-19T00:50:04+00:00

I have 3 class, Root, CFile, SubDirectory. Root is a abstract class. CFile and

  • 0

I have 3 class, Root, CFile, SubDirectory. Root is a abstract class. CFile and SubDirectory are derived from Root. CFile has attributes: name:string , size:int, level:int. SubDirectory has attributes: name:string, size:int, level:int,a vector, which contains both files and directories and a function void add() to push the file or directory into the vector. If a file in a directory, file’s level is higher than the directory’s by one. All setters and getters are defined.

Now, I have a file called DirRead.h that can struct all the entries in the current diretory (computer’s folder). Each entry has a filename, size, level and type (either File or Directory). In the main function, I’m asked to use the information from DirRead as input to construct the hierarchy of file system (using CFile and SubDirectory). DirRead.h conducts pre-order triversal. Recursion is not accepted in this case (I tried, and DirRead.h reported error). I’m asked to use stack to deal with the input, but I don’t know how. Apparently level is really important here. I have tried to create a stack and push all the files and directories into the stack, then compare the level to form the hierarchy. But Root doesn’t have Add function, there’s no way to add CFile into SubDirectory because they are all Root*. Anyone knows how to do this? Thx.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-19T00:50:05+00:00Added an answer on June 19, 2026 at 12:50 am

    You use the stack to keep track of directories you haven’t explored yet. You can use the following algorithm:

    1. Push the root directory onto the stack.

    2. Pop the top entry off the stack. If the stack is empty, stop, you’re done.

    3. Traverse the directory you pulled off the stack. Add every file and directory in it into your data structure. Also, push every directory you find onto your stack.

    4. Go to step 2.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In php I have a ROOT class from which all other classes inherit. abstract
I am using Delphi. I have a root class and many derived class from
I have an application which resides in ROOT. This application has a java class(in
Let's say we have a class Root that contains an array of an abstract
I have a class inherited from UITableViewController and this is also the root class.
I have a class Department: class Department{ string des; string name; string id; List<Department>
I have a class in my domain model root that looks like this: namespace
I have a class with n elements, and a property that returns the root
I have a binary tree class that is created with a root node and
In application.rb, I have config.autoload_paths += %W(#{config.root}/lib So when I modify a class under

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.