title: Why do I keep getting error message "a function-definition is not allowed here before '{' token" in C++?
body: <p>For a project I have to create a simple, menu-driven conversion software package that the user enters a number and converts among other things, meters to feet, feet to meters, etc. I have to use a function for each conversion. I have started with the meters to feet function. But when I  compile it I get the error message "a function-definition is not allowed here before '{' token." How do I fix this? I am also a beginner.</p>
  
  <pre><code> #include &lt;iostream&gt;
  
  using namespace std;
  
  double meters_infeet(double meters){
  double totalmetersinfeet = (meters * 3.280839895);
  return totalmetersinfeet;
  }
  double feet_inmeters(double feet){
   double totalfeetinmeters = (feet / 3.280839895);
  return totalfeetinmeters;
  }   
   double area_infeet(double length_inmeters, double width_inmeters){
   double totalareainfeet = (length_inmeters * 3.280839895) 
  return totalareainfeet;
   }
   double area_inmeters(double length_infeet, double width_infeet){
   double totalareainmeters = (length_infeet / 3.280839895) 
  return totalareainmeters;
   }
  
  
  
  int main()
   {
   int choice;
   double meters;
   double feet;
   double length_inmeters;
   double width_inmeters;
   double length_infeet;
   double  width_infeet;
  
   do{
  
   cout &lt;&lt; "English-Metric Junior" &lt;&lt; endl;
   cout &lt;&lt; "1)Convert from meters to feet" &lt;&lt; endl;
   cout &lt;&lt; "2) Convert from feet to meters" &lt;&lt; endl;
   cout &lt;&lt; "3) Compute the area of a rectangle in square feet given width
   cout &lt;&lt; "4) Compute the area of a rectangle in  meters given the length
   cout &lt;&lt; "5) Quit the Program" &lt;&lt; endl;
   cout &lt;&lt; "Please enter a number (1-5)" &lt;&lt; endl;
   cin &gt;&gt; choice;
   }while(choice &gt; 5);
  
  
  
   switch (choice)
  {
  case 1:
  cout &lt;&lt; "Enter Meters" &lt;&lt; endl;
  cin &gt;&gt; meters;
  cout &lt;&lt; meters_infeet(meters)&lt;&lt; "Feet " &lt;&lt; endl;
  break;
  case 2:
  cout &lt;&lt; "Enter Feet" &lt;&lt; endl;
  cin &gt;&gt; feet;
  cout &lt;&lt; feet_inmeters(feet)&lt;&lt; "Meters " &lt;&lt; endl;
  break;
  case 3:
  cout &lt;&lt; "Enter length in meters" &lt;&lt; endl;
  cin &gt;&gt; length_inmeters;
  cout &lt;&lt; "Enter width in meters" &lt;&lt; endl;
   cin &gt;&gt; width_inmeters;
  cout &lt;&lt; area_infeet( length_inmeters, width_inmeters) &lt;&lt; endl;
  break;
  case 4:
  cout &lt;&lt; "Enter length in feet" &lt;&lt; endl;
  cin &gt;&gt; length_infeet;
  cout &lt;&lt; "Enter width in feet" &lt;&lt; endl;
  cin &gt;&gt; width_infeet;
  cout &lt;&lt; area_inmeters(length_infeet, width_infeet)&lt;&lt; endl;
  break;
  </code></pre>