Ok, I am a college student, and have been working on a Character Sheet program. Right now all I am trying to accomplish is to create a class for the main menu, the class consists of two parts right now, and the second one is where I am getting this warning with. It causes the program to freeze and close, I was wondering if there is another way to program this part, all it should do is act like a normal int to allow menu selection, and I don't know if I am going about this the right way. I have been tearing my hear out for about a week or so with this error and have now resorted to actually posting it.
I am using Visual Studio 2012 Ultimate for this as well.
Here is my main, note that it has a lot of empty spaces since I am just trying to get the menu to work:
If I take out return menuSelection(); it kindly tells me it must return a value:
Error 1 error C2561: 'mMenu::menuSelection' : function must return a value c:\users\yhivu\documents\~school\int. programming\final project\character sheet\character sheet\mmenu.cpp 19 1 Character Sheet
So, as you see I do not know what to put here, I was just seeing if I could get some advice as to what to put here.
What you originally had was "This function must return what it returns", which worked, until it used up all your memory and crashed. Then you changed it to "This function must return something but I won't tell you what", and the compiler flat out could not guess what you wanted it to do.
Here is an example of a function that returns a value:
1 2 3 4 5 6 7
std::cout << "Enter a number: ";
int x = 0;
std::cin >> x;
I understand the example of the function returning the value, but I can't make my class value = 0. So, do I need multiple values in my class to ask for a simple integer so it doesn't keep returning itself to itself?
1 2 3 4
If so, how do I implement this into the main file?
Did you miss line 5? The 0 is overwritten when the suer enters valid input, but if the suer enters e.g. "hello" that would fail and x would keep its value of 0. If not assigned to it would have random memory, which is bad.
Well, to put it simply a value 1-6, i could easily take this out of the class, and have a normal int allow for the menu selection, I was just hoping to have my main at a minimum, allowing the classes to do all of the work. But at this point I don't understand how I am going to allow this implement to work out.
Sorry, I didn't see your last post, I did try that but it still has the recursion warning and crashes. Even with the 0 value.
The value is determined by the user, then the menu itself will be able to load the appropriate page for the user. I feel like I am missing a large chunk of code and this is feeling more complex than it should right now.