title: Designing folder/file system?
body: <p>I'm trying to create a folder/file system similar to the ones used in most OSes.
  Basically I've figured out that I should use three classes; <code>File</code>, <code>Folder</code>, and a common base class. Let's call it <code>Common</code> for the sake of creativity.
  Here's how I thought the headers for those three should look like:</p>
  
  <h3>common.h</h3>
  
  <pre><code>class Common {
      string m_name; // all files and folders have a name
      Folder* m_parent; // all files and folders can have a parent
  
  public:
      virtual void open() = 0; // executed when folder or file is opened by user
      virtual void draw() const; // all files and folders can be printed
      virtual void setParent(Folder* parent);
      virtual Folder* getParent() const;
  };
  </code></pre>
  
  <h3>folder.h</h3>
  
  <pre><code>class Folder : public Common {
      vector&lt;Common*&gt; m_children; // folders can contain other files and folders
                                  // whereas files cannot
  
  public:
      virtual void open(); // folder opens; basically shows the content
      virtual void draw() const; // folder draws differently
  };
  </code></pre>
  
  <h3>file.h</h3>
  
  <pre><code>class File : public Common {
      // not really "files", they just call a function when opened
      funcptr m_openAction;
  
  public:
      virtual void open(); // calls m_openAction() when opened
  };
  </code></pre>
  
  <p>As you can see, the problem is that my base class <code>Common</code> should be able to know it's subclass <code>Folder</code>, which is bad behaviour and shouldn't be done (at least according to my teacher).
  This makes it impossible for me to code the system like I had planned to.</p>
  
  <p>How should such system be designed?</p>