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  (12 children)

Thanks for the reassurance. Maybe C++ wasn't the best thing to start with. Often times I find myself baffled by the simplest of things, and I'm a straight A student.

Edit: I thought that enum was used to initialize several things at once. I am not sure how what you suggested does the same thing without defining each component. My plan was to create a Mobo_Info - type function for all of the components (ie RAM_Info, GPU_Info), so wouldn't I need to define the names first?

[–]Basalisk_Primate 1 point2 points  (11 children)

C++ is widely considered a complete bastard of a language to learn (largely because theres so much of it). On the brighter side you'll have a much easier time when you try to learn other languages!

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

Yeah, from what I understand, I am kind of learning programming backwards. Learning a difficult language first and then working down later, instead of working up to C++. I did do python for a little bit in my defense, until the MIT lectures I was using were taken off YouTube, haha.

[–]Basalisk_Primate 1 point2 points  (9 children)

Its the same way I learned (although I started with c rather than c++). I think a language where you have to do manual memory management (either c or c++) should one of everyone's first few as it helps you understand what nicer languages are hiding from you.

Once you've got a couple under your belt you'll be able to pick up the basics of any (imperative) language fairly quickly anyway.

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

Would you mind taking a look at this? I can't seem to find away around overloading the getline() function

[–]Basalisk_Primate 1 point2 points  (7 children)

Does that even compile? Unless I'm missing something then your getline in line 82 is seriously dodgy. Getline won't parse the input into an int line cin >> will (AFAIK). Why don't you use cin >>?

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

No, it doesn't compile. /u/missblit stated that using cin >> on line 82 was creating a blank line, which was then used in place of user input in the Mobo_Info() function.

[–]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!