Thread: Evil Error: Missing Function Header

  1. #1
    Registered User
    Join Date
    Jun 2008
    Posts
    11

    Evil Error: Missing Function Header

    Here comes my second question. It's probably got a really easy answer, but here's my code and error list (respectively):


    Code:
    #include "SimpleAssistant.h"
    
    #include <string>
    
    using namespace std;
    
    int math (int x, int y);
    
    int main();
    {
    	int menu_choice;
    	int input;
    	int x;
    	int y;
    
    	cout<< "Hello. I'm your personal Simple Assistant.\n";
    	cin.get();
    	cout<< "Please select an option from the menu.\n";
    	cout<< "After carrying out an action, type '01' to make another choice or '00' to exit.'\n";
    	cout<< "1 = Multiply numbers\n";
    	cin>> input;
    	if (input==1) 
    	{
    		cout<< "Please input two numbers to be multiplied.\n";
    		cin>> x >> y;
    		cin.get();
    		cout<< "The answer is: "<< math (x, y) <<"\n";
    		cin.get();
    	}
    	cin>> menu_choice;
    	if (menu_choice==01)
    	{
    		cout<< "Please select an option from the menu.\n";
    		cout<< "After carrying out an action, type '01' to make another choice or '00' to exit.'\n";
    		cin>> input;
    		if (input==1)
    		{
    			cout<< "Please input two numbers to be multiplied.\n";
    			cin>> x >> y;
    			cin.get();
    			cout<< "The answer is: "<< math (x, y) <<"\n";
    			cin.get();
    		}
    	}
    	if (menu_choice==00)
    	{
    		cin.get();
    		return 0;
    	}
    	cin.get();
    }

    Code:
    ------ Build started: Project: SimpleAssistant, Configuration: Debug Win32 ------
    Compiling...
    SimpleAssistant.cpp
    c:\documents and settings\klope family\my documents\visual studio 2008\projects\simpleassistant\simpleassistant\simpleassistant.cpp(10) : error C2447: '{' : missing function header (old-style formal list?)
    Build log was saved at "file://c:\Documents and Settings\Klope Family\My Documents\Visual Studio 2008\Projects\SimpleAssistant\SimpleAssistant\Debug\BuildLog.htm"
    SimpleAssistant - 1 error(s), 0 warning(s)
    ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

    P.S. Here's the contents of "SimpleAssistant.h":

    Code:
    #include <iostream>
    
    int math (int x, int y)
    {
    	return x * y;
    }
    I really can't see where the problem is. It says the "missing function header" is on line 10, but all that's on that line is a bracket--a properly placed bracket, I do believe, also. What's the problem here?

  2. #2
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,895
    There are three problems with SimpleAssistant:
    1) Missing include guards.
    2) Unnecessary include.
    3) Contains implementation of a non-template, non-static, non-inline function.

    The error is due to the stray semicolon after main's header.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  3. #3
    Registered User
    Join Date
    Jun 2008
    Posts
    11
    Gah. I put that semicolon there against my best judgment, and it zapped one error. Now I remove it and the program runs. Something happened there...Okay, fixed.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Getting an error with OpenGL: collect2: ld returned 1 exit status
    By Lorgon Jortle in forum C++ Programming
    Replies: 6
    Last Post: 05-08-2009, 08:18 PM
  2. Troubleshooting Input Function
    By SiliconHobo in forum C Programming
    Replies: 14
    Last Post: 12-05-2007, 07:18 AM
  3. c++ linking problem for x11
    By kron in forum Linux Programming
    Replies: 1
    Last Post: 11-19-2004, 10:18 AM
  4. Header file for "fix" function ?
    By Rex in forum C++ Programming
    Replies: 1
    Last Post: 04-08-2003, 04:42 AM
  5. Interface Question
    By smog890 in forum C Programming
    Replies: 11
    Last Post: 06-03-2002, 05:06 PM