Factory

#include 

using namespace std;


//an interface
class ICreature
{
public:
  virtual string GetName() = 0;
};

// concrete class                                                                                        
class Hobbit : public ICreature
{
public:
  string GetName(){ return "Frodo"; }
};

// the factory
class CreatureFactory
{

public:

  /* you can return different objects (that implement ICreature)
           based on args that could be passed in to this call or the
           state of the system.
           This simply returns a concrete class that implemnts ICreature
  */
  ICreature* GetCreature()
  {
    ICreature* pCreature = nullptr;

    pCreature =  new Hobbit();
    return pCreature;
  }

};


int main()
{
  cout << "Class:main, Method:main\n";


  ICreature* aCreature;

  CreatureFactory fact;
  aCreature = fact.GetCreature();

  cout << aCreature->GetName() << endl;

}