title: How to correctly create a base class in c++?
body: <p>I'm learning C++ by myself, "creating" a RPG. However, I'm stuck at point of creating a class named Item, which would be the base class for all game items (or if it was in Java, an interface). Here's my code:</p>
  
  <pre><code>class Item {
  
      public:
  
      virtual const char* GetName() = 0;
  };
  </code></pre>
  
  <p>I read something about "pure virtual" functions, which I'm using.</p>
  
  <p>My Character class, where I use my Item:</p>
  
  <pre><code>class Character {
  
    // some code...
  
    void ConsumeItem(Item item);
  
  }
  </code></pre>
  
  <p>But gcc gives me this error:</p>
  
  <pre><code>g++ -Wall -o adventure character.cpp adventure.cpp
  In file included from adventure.cpp:3:0:
  character.h:36:24: error: cannot declare parameter ‘item’ to be of abstract type ‘Item’
  item.h:4:7: note:   because the following virtual functions are pure within ‘Item’:
  item.h:11:22: note:     virtual const char* Item::GetName()
  </code></pre>
  
  <p>I'm very new to OOP in C++, as it is very different from Java. I already read some articles about abstract classes in C++, but I just can't get it working.</p>
  
  <p>Can you please tell me the right way to achieve this?</p>