0

I receive the errors:

cs163hw1.cpp:41:24: error: no ‘int menutype::run_prog()’ member function declared in class ‘menutype’

and

main.cpp:18:7: error: ‘struct menutype’ has no member named ‘run_prog’

When attempting to compile my program with the associated code (spanning the appriprait .cpp and .h files):

int main(int argc, char ** argv){
...
menu.run_prog();
...

class menutype{
public:
  menutype(int);
  int display();
  int run_prog();
private:
  extras list;
  person menup;
};

int menutype::run_prog(){
bool exit = false;
int input;
while(!exit){
    input = 0;
    while(input < 1 || input > 4)
        input = display();
    switch(input){
        case 1 : 
            break;
        case 2 :
            break;
        case 3 :
            break;
        case 4 : exit = true;
            break;
        default :
            break;
    }
}
}

I have no idea why this is happening, any guesses?

Flexo1515
  • 1,007
  • 1
  • 10
  • 27
  • 2
    My guess is that you're calling `menu.run_prog()` before the class is even defined. As as matter of fact, I bet that *is* the problem. – David G Oct 12 '12 at 00:37
  • Can you include in your post the #includes for each of the .cpp files? Also whether you have an include guard (e.g. #ifdef macro) in your header file that might be conflicting with another header? – James Beilby Oct 12 '12 at 00:43
  • @JamesBeilby, Header guards are `#ifndef`. – chris Oct 12 '12 at 00:48
  • @chris Typo on my behalf, you are correct of course this is usually the case. – James Beilby Oct 12 '12 at 00:52

1 Answers1

0

You need to have the class menutype declared above main(). Better still is to move the class to its own dedicated file called menutype.cpp and include the header in main's source file. As you have described it, the complier has no knowledge of menutype yet as its parsing the source file from the top of the file.

bobestm
  • 1,334
  • 1
  • 9
  • 8