Local function definitions are illegal?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • martinezgeno199
    New Member
    • Sep 2011
    • 1

    Local function definitions are illegal?

    Been at this for a while now. Can't for the life of me figure it out... All help is very much appreciated.

    Code:
    #include "Menu2.h"
    #include <iostream>
    //additional includes
    
    using namespace std;
    
    Menu::Menu() 
    {
    
    
    void Menu::display_main_menu() const 
    {
    	cout << "Here is the MAIN MENU \n";
    }
    void Menu::display_info() const
    {
    	cout << "Here is the Info requested \n";
    }
    
    void Menu::read()
    {
    	cout << "Read file name then read store data \n";
    	
    }
    void Menu::show() const 
    {
    	cout << "Show queries \n";
    		
    }
    void Menu::find() const 
    {
    	cout << "Find queries \n";
    }
    void Menu::update()  
    {
    	cout << "Update queries \n";
    }
    
    }
    errors are

    1>.\menu.cpp(12 ) : error C2601: 'Menu::display_ main_menu' : local function definitions are illegal
    1> .\menu.cpp(8): this line contains a '{' which has not yet been matched
    1>.\menu.cpp(16 ) : error C2601: 'Menu::display_ info' : local function definitions are illegal
    1> .\menu.cpp(8): this line contains a '{' which has not yet been matched
    1>.\menu.cpp(21 ) : error C2601: 'Menu::read' : local function definitions are illegal
    1> .\menu.cpp(8): this line contains a '{' which has not yet been matched
    1>.\menu.cpp(26 ) : error C2601: 'Menu::show' : local function definitions are illegal
    1> .\menu.cpp(8): this line contains a '{' which has not yet been matched
    1>.\menu.cpp(31 ) : error C2601: 'Menu::find' : local function definitions are illegal
    1> .\menu.cpp(8): this line contains a '{' which has not yet been matched
    1>.\menu.cpp(35 ) : error C2601: 'Menu::update' : local function definitions are illegal
    1> .\menu.cpp(8): this line contains a '{' which has not yet been matched

    this makes no sense to me at all.. Thanks again to everyone
    Last edited by Niheel; Sep 30 '11, 02:18 AM. Reason: code tags
  • Banfa
    Recognized Expert Expert
    • Feb 2006
    • 9067

    #2
    The definition of Menu::Menu starts at line 7 and finishes at line 39. All other function definitions appear between these 2 lines so all the other function definitions are local to Menu::Menu which is not allowed.

    Move the } from line 39 to line 9.

    Comment

    Working...