Error C3861: 'menu': identifier not found

This is a discussion on Error C3861: 'menu': identifier not found within the C++ Programming forums, part of the General Programming Boards category; Hi all again, I'm having some trouble now with calling functions. Even tough I have a header file being called ...

  1. #1
    Registered User
    Join Date
    May 2008
    Posts
    20

    Unhappy Error C3861: 'menu': identifier not found

    Hi all again,

    I'm having some trouble now with calling functions. Even tough I have a header file being called in the correspondent .cpp file it gives me the consequent error (in Visual C++ 2008 Expression Edition):

    .\AirLine.cpp(113) : error C3861: 'menu': identifier not found
    Here it goes the code (I edited the code that I thought it wasn't useful since it's a bit long)

    AirLine.h
    Code:
    #pragma once
    
    #include "Form1.h"
    #include "Person.h"
    
    #include <cstdlib>
    #include <iostream>
    #include <string>
    #include <map>
    
    using namespace std;
    
    class AirLine
    {
    	public:
    		//int main(array<System::String ^>);
    		void menu(void);
    		void loginUser (void);
    		void registerUser(void);
    };
    AirLine.cpp
    Code:
    // AirLine.cpp : main project file.
    
    #include "stdafx.h"
    #include "AirLine.h"
    
    static Person person;
    
    //[STAThreadAttribute]
    void registerUser()
    {
           (...)
    		registerUser();
           (...)
    }
    
    void loginUser ()
    {
    	(...)
    		menu(); // the error above goes here
    	(...)
    }
    
    void menu()
    {
    	(...)
    		switch(option)
    		{
    			case 0: exit(1);
    			case 1: loginUser(); break;
    			case 2: registerUser(); break;
    		}
    	}
    }
    
    int main(array<System::String ^> ^args)
    {
    	menu();
    	
    	return 0;
    }
    I created the header file since I need to call menu() before and after the declaration of that function, as you can see above, and I thought it would solve my problems. Seems it doesn't.

    Any guesses? :\

    Thanks in advance,
    Joćo

  2. #2
    Captain Crash brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,274
    Quote Originally Posted by blacknail View Post
    (I edited the code that I thought it wasn't useful since it's a bit long)
    We kind of hate that... If we're not seeing the real code we can't find the bug. If your code is truly tremendous, post it as an attachment instead of in-line, but in any case please always submit the entire code.
    Code:
    //try
    //{
    	if (a) do { f( b); } while(1);
    	else   do { f(!b); } while(1);
    //}

  3. #3
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    So there's menu() and there's AirLine::menu(). The prototype for the second (in the class) won't help you find the first. (The same thing would be true for registerUser and loginUser; you're declaring the second, and defining the first.)

  4. #4
    Registered User
    Join Date
    May 2008
    Posts
    20
    Solved my problem, I decided to separate the AirPlane class from the class with the main() function. I shouldn't have mixed up the main project file with functions of another class, but since I was not having problems I kept going...

    Thanks again for all the support!

    [[]]
    Jo&#227;o

  5. #5
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Posts
    23,027
    As I see, loginUser tries to call menu that is... defined later. Oops.
    The compiler doesn't know of the existence of the menu function yet.
    So how do you solve that? Easy. You create a declaration of the function (all of the functions), stuff them into a header and include it in the .cpp file, as well as any other file that's going to use the functions inside that .cpp file.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  6. #6
    Registered User
    Join Date
    Sep 2009
    Posts
    1
    Hi, i am currently facing the same problem...do you mind giving a few examples on how to declare the functions inside the header?

  7. #7
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Posts
    23,027
    Code:
    void menu(); // Declaration. Goes into header.
    void menu() // Definition. Goes into .cpp file.
    {
    }
    
    class MyClass // Class definition. Goes into header.
    {
    public:
        void menu();
    };
    
    void MyClass::menu() // Class implementation. Goes into source file (.cpp file).
    {
    }
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. An error is driving me nuts!
    By ulillillia in forum C Programming
    Replies: 5
    Last Post: 04-04-2009, 10:15 PM
  2. Problem with Mouse Over Menu!!! HELP!!!
    By SweeLeen in forum C++ Programming
    Replies: 3
    Last Post: 02-09-2006, 02:10 AM
  3. Best "Menu" method?
    By SSJMetroid in forum Game Programming
    Replies: 11
    Last Post: 12-08-2005, 12:05 AM
  4. Why wont my function exit correctly?
    By LightsOut06 in forum C Programming
    Replies: 2
    Last Post: 10-09-2005, 10:23 PM
  5. Going out of scope
    By nickname_changed in forum C++ Programming
    Replies: 9
    Last Post: 10-12-2003, 07:27 PM

Tags for this Thread


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21