C Board  

Go Back   C Board > General Programming Boards > C++ Programming

Reply
 
LinkBack Thread Tools Display Modes
Old 11-25-2008, 05:09 PM   #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):

Quote:
.\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
blacknail is offline   Reply With Quote
Old 11-25-2008, 05:44 PM   #2
Senior software engineer
 
brewbuck's Avatar
 
Join Date: Mar 2007
Location: Portland, OR
Posts: 5,381
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.
__________________
"Congratulations on your purchase. To begin using your quantum computer, set the power switch to both off and on simultaneously." -- raftpeople@slashdot
brewbuck is offline   Reply With Quote
Old 11-25-2008, 05:47 PM   #3
and the Hat of Guessing
 
tabstop's Avatar
 
Join Date: Nov 2007
Posts: 8,740
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.)
tabstop is offline   Reply With Quote
Old 11-25-2008, 06:14 PM   #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ão
blacknail is offline   Reply With Quote
Old 11-26-2008, 07:08 AM   #5
Mysterious C++ User
 
Join Date: Oct 2007
Posts: 14,099
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.
__________________
Using: Microsoft Windows™ 7 Professional (x64), Microsoft Visual Studio™ 2008 Team System
I dedicated my life to helping others. This is only a small sample of what they said:
"Thanks Elysia. You're a programming master! How the hell do you know every thing?"
Quoted... at least once.
Quote:
Originally Posted by cpjust
If C++ is 2 steps forward from C, then I'd say Java is 1 step forward and 2 steps back.
Elysia is offline   Reply With Quote
Old 09-11-2009, 01:32 AM   #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?
splicer is offline   Reply With Quote
Old 09-11-2009, 09:34 AM   #7
Mysterious C++ User
 
Join Date: Oct 2007
Posts: 14,099
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).
{
}
__________________
Using: Microsoft Windows™ 7 Professional (x64), Microsoft Visual Studio™ 2008 Team System
I dedicated my life to helping others. This is only a small sample of what they said:
"Thanks Elysia. You're a programming master! How the hell do you know every thing?"
Quoted... at least once.
Quote:
Originally Posted by cpjust
If C++ is 2 steps forward from C, then I'd say Java is 1 step forward and 2 steps back.
Elysia is offline   Reply With Quote
Reply

Tags
c3861, error, found, identifier

Thread Tools
Display Modes

Forum Jump

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


All times are GMT -6. The time now is 07:59 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.0 RC2

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