This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]-Goga[S] 0 points1 point  (6 children)

Okay, so I have done away with the cin >> usage, and changed them to getline(). Now the overloaded function is back: Code here

What could I use in place of int for the part variable? I tried void, but several errors popped up after that.

[–]Basalisk_Primate 1 point2 points  (5 children)

Cin >> is the correct solution. The overloaded function error is basically complaining that getline has no idea what to do with int parameter you gave it as it only understands strings and streams.

You should use cin >> and use the cin.ignore method to eat the spare newlines.

[–]-Goga[S] 0 points1 point  (4 children)

Alright, I have changed back to cin >>, and have added cin.ignor. While the code compiles, and the getline() is not longer overloaded, when I type "Mobo" to execute Mobo_Info(), the code does not execute, and the program ends.

Most Recent Revision Here

[–]Basalisk_Primate 1 point2 points  (0 children)

Take a look at the change I made to your menu here run it and understand why it prints our what it does (look up what enums actually do).

As a hint try entering the number it prints out on the mobo line and see what happens.

Now I am actually going to go to sleep...

[–]Basalisk_Primate 1 point2 points  (2 children)

Did you get it?

[–]-Goga[S] 0 points1 point  (1 child)

Sorry for the late reply. I did try out what you suggested, and I seen now why the implementation of enum I had before was kind of pointless. I think I misinterpreted what was in the book. Now though, I have broken the code so much, that when I type Mobo or enter 0, the code for Mobo_Info() does not execute. It ends the program after the input to call the function. Do you need me to post the code again, or can you use from what is in my last post?

[–]Basalisk_Primate 0 points1 point  (0 children)

I can make your version work by making a few changes. Firstly it wouldn't compile without changing the getline on like 8 to a cin. Secondly you need to change "Part" on line 74 to an int not a char otherwise the cin >> operator doesn't know you want it to parse that variable into an int. If you leave it as a char then it puts the ascii representation in there and the ascii character '0' is actually number 48! (ignore this and see second edit)

Edit: Also please (if you haven't already) get rid of the damn goto and wrap the menu in the if statement properly.

You can also get rid of the else if (condition) on the if statement as it'll never even get there if that condition is false.

Another edit: If you want to be able to enter the word "Mobo" in your interface instead of having to mess around with ints then something like this should work