title: STL map and pure virtual base class
body: <p>I have not used C++ in a long time. I'm trying to display some polymorphic behavior:</p>
  
  <pre><code>class func {
      public:
      virtual void print() = 0;
  };
  
  class func1 : public func {
      public:
      void print () { cout &lt;&lt; "FUNC 1" &lt;&lt; endl; };
  };
  
  class func2 : public func {
     public:
       void print () { cout &lt;&lt; "FUNC 2" &lt;&lt; endl; };
  };
  
  
  static map&lt;string,func *&gt; myMap;
  static func1 f1 = func1 ();
  static func2 f2 = func2 ();
  myMap["func1"] = &amp;f1;
  myMap["func2"] = &amp;f2;
  </code></pre>
  
  <p>So In my main function, when I call:</p>
  
  <pre><code>myMap["func1"]-&gt;print();
  myMap["func2"]-&gt;print();
  </code></pre>
  
  <p>I would expect:</p>
  
  <pre><code>FUNC 1
  FUNC 2
  </code></pre>
  
  <p>Not sure if this is the right way to do this. When I compile the code, it gives me this error:</p>
  
  <pre><code>test.cc:31: error: expected constructor, destructor, or type conversion before ‘=’ token
  test.cc:32: error: expected constructor, destructor, or type conversion before ‘=’ token
  </code></pre>
  
  <p>Which refers to these lines: </p>
  
  <pre><code>myMap["func1"] = &amp;f1;
  myMap["func2"] = &amp;f2;
  </code></pre>
  
  <p>Thank you.</p>