title: C++ compiler error: “invalid declarator before”
body: <p>Here's my code. When compiling I get the error </p>
  
  <blockquote>
    <p>invalid declarator before ‘geometry’</p>
  </blockquote>
  
  <p>at line 16 and line 48, I am not sure what I am doing wrong. Please advise.</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;memory&gt;
  #include &lt;vector&gt;
  using namespace std;
  class FactGeometry {   //Factory class
  public:
      static std::shared_ptr&lt;FactGeometry&gt;geometry( int choice );
      virtual void calcArea() = 0;
  };
  
  class CalcRectangle :public FactGeometry {
      void calcArea() {
          double ll, bb, Area;
          std::cout &lt;&lt; "\nEnter the length = ";
          std::cin &gt;&gt; ll;
          std::cout &lt;&lt; "\nEnter the breadth = ";
          std::cin &gt;&gt; bb;
          Area = ll * bb;
          std::cout &lt;&lt; "\nArea = " &lt;&lt; Area;
      }
  }; //end class
  
  class CalcTraingle :public FactGeometry {
      void calcArea() {
          double bb, hh, Area;
          std::cout &lt;&lt; "\nEnter the base = ";
          std::cin &gt;&gt; bb;
          std::cout &lt;&lt; "\nEnter the height = ";
          std::cin &gt;&gt; hh;
          Area = 0.5 * bb * hh;
          std::cout &lt;&lt; "\nArea = " &lt;&lt; Area;
      }
  };
  
  FactGeometry std::shared_ptr&lt;FactGeometry&gt;geometry( int choice ) {
      switch ( choice ) {
      case 1: return shared_ptr&lt;FactGeometry&gt;( new CalcRectangle );
          break;
      case 2: return shared_ptr&lt;FactGeometry&gt;( new CalcTraingle );
          break;
      default: std::cout &lt;&lt; "EXIT";
          break;
      }
  } //end class
  
  int main() {
      cout &lt;&lt; "Hello World";
      int choice;
      std::vector&lt;std::shared_ptr&lt;FactGeometry&gt;&gt; table;
      while ( 1 ) {
          std::cout &lt;&lt; "1. Rectangle 2. Triangle";
          std::cout &lt;&lt; "Enter Choice :";
          std::cin &gt;&gt; choice;
          if ( ( choice != 1 ) || ( choice != 2 ) )
              break;
          else
              table.push_back( FactGeometry::make_shared&lt;FactGeometry&gt;geometry( choice ) );
      }
      for ( int i = 0; i &lt; table.size(); i++ ) {
          table[i];
      }
      return 0;
  }
  </code></pre>
  
  <p>I am writing code for Factory Method class but I am getting this error as invalid declarator before ‘geometry’.I am not sure what I am doing wrong</p>