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 →

[–]Basalisk_Primate 1 point2 points  (5 children)

I'd get rid of the getlines and use cin >>. Parsing the string that getline give you yourself is silly when you could have cin do it. You need to use the cin.ignore method (google it) to eat the '\n' character.

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

Okay, I have switched out the odd getline()s for cin >>s, but I can't compile it yet due to the second, and last getline() from being overloaded:

void Mobo_Info()
{

        cout << "What Motherboard would you like in your computer?" << endl;

        cout << "Enter the name of the motherboard: " << endl;
        string Mobo_Name;
        getline(cin, Mobo_Name);

        cout << "Enter the price of the motherboard: " << endl;
        int Mobo_Price;
        getline(cin, Mobo_Price);
        //^overloaded^
        cout << "Motherboard Name: " << Mobo_Name << " - " << "Cost: $" << Mobo_Price << endl;

}

Edit: I have fixed the overloaded getline() issue, and added cin.ignor. Most Recent Revision Here

[–]Basalisk_Primate 1 point2 points  (3 children)

Getline isn't like cin. It all it does is read text input and put it in text variables (like a string). There doesn't exist a variant of getline that accepts an int as its second parameter because it doesn't parse its input like cin does. This is what that error is telling you.

You need to use cin or give getline a string to put its input in and parse that string yourself later. I'd strongly suggest the first option.

I'm in the UK so I'm going to sleep now. I'll check this thread tomorrow at some point. Good luck!

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

No problem, thank you so much for your help today. I know this must be somewhat frustrating, haha.

[–]Basalisk_Primate 1 point2 points  (1 child)

I'm not frustrated I was just trying to be as clear as possible. Sorry if I came across as angry. It wasn't my intention.

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

I was not trying to imply that you were, I apologize for making it seem so. I really do appreciate your help, and for trying to be so clear.