title: Abstract object cannot declare
body: <p>I'm having a problem with abstract/virtual classes, a replication of the problem here:</p>
  
  <pre><code>#include &lt;iostream&gt;
  
  class A
  {
  protected:
      virtual std::string getDateTime() = 0;
      virtual void Write(std::string data, bool addDate) = 0;
      virtual bool CheckFile() = 0;
      virtual bool OpenFile(std::string path) = 0;
      virtual void CloseFile() = 0;
  };
  
  class B
      : public A
  {
  public:
      virtual std::string ToString() { return ""; };
      virtual void Write(std::string data) { };
  };
  
  class C
      : public A
  {
  protected:
      std::string getDateTime()
      {
          return "TODAY";
      };
  
      void Write(std::string data, bool addDate)
      {
          std::cout &lt;&lt; "BasicClassA Write" &lt;&lt; std::endl;
      };
  
      bool CheckFile()
      {
          std::cout &lt;&lt; "BasicClassA CheckFile" &lt;&lt; std::endl;
          return true;
      };
  
      bool OpenFile(std::string path)
      {
          std::cout &lt;&lt; "BasicClassA OpenFile" &lt;&lt; std::endl;
          return true;
      };
  
      void CloseFile()
      {
          std::cout &lt;&lt; "BasicClassA CloseFile" &lt;&lt; std::endl;
      };
  };
  
  class D
      : public B,
        public C
  {
  public:
      BasicClassB();
      virtual ~BasicClassB();
  
      std::string ToString()
      {
          return "BasicClassB tostring";
      };
  
      void Write(std::string data)
      {
          std::cout &lt;&lt; "BasicClassB Write" &lt;&lt; std::endl;
      };
  };
  
  int main(int ac, char *av[])
  {
      BasicClassB b;
      std::cout &lt;&lt; b.ToString() &lt;&lt; std::endl;
      b.Write("");
      return 0;
  }
  </code></pre>
  
  <p>This has a compile error: </p>
  
  <p>../src/main.cpp: In function ‘int main(int, char**)’:<br>
  ../src/main.cpp:82: error: cannot declare variable ‘b’ to be of abstract type ‘BasicClassB’<br>
  ../src/main.cpp:64: note:   because the following virtual functions are pure within ‘BasicClassB’:<br>
  ../src/main.cpp:13: note:   virtual std::string BaseClassA::getDateTime()<br>
  ../src/main.cpp:14: note:   virtual void BaseClassA::Write(std::string, bool)<br>
  ../src/main.cpp:15: note:   virtual bool BaseClassA::CheckFile()<br>
  ../src/main.cpp:16: note:   virtual bool BaseClassA::OpenFile(std::string)<br>
  ../src/main.cpp:17: note:   virtual void BaseClassA::CloseFile()  </p>
  
  <p>Perhaps I'm missing the point here, but the implementation of BaseClassA (being BasicClassA) should contain these functions, and since BasicClassB is subclassed from BasicClassA as well, it should also contain these functions?</p>
  
  <p>What am I missing? What should I do to make this compile?</p>
  
  <p>[<strong>edit</strong>]
  <code>I updated the class names as suggested by the comment</code><br>
  For clarification: I used pure virtual in the class A to <strong>force any</strong> of the children to implement the functions.</p>
  
  <p>It seems virtual inheritance is what I need, however, I don't seem to get the correct way on how to do this in my case...</p>
  
  <p>The goal is to have several "base" classes, kind of like interfaces, forcing the children to implement the functions, but any children of those should inherit the overriden function (just like virtual inheritance)</p>
  
  <p>However, using any combination of
      class Any : public virtual Anyother { }
  doesn't work out and always gives the same compile error (the one above). Perhaps I need to change more than just the virtual in the inheritance?</p>