ABz B👹anaz
Grandfathered In
This country is (now less of) a shitshow.
Posts: 1,989
|
Post by ABz B👹anaz on Jun 17, 2021 12:18:13 GMT -5
I am now taking a C++ course. Prior to this I have learned some Python, PHP, and Visual Basic. A LONG time in the past I learned some BASIC and other random things as a kid.
I am really excited about this course, and so far liking C++ quite a bit. It's handling of numbers is kind of silly, but I feel like because I had experience with Python as an "easier" language, I'm picking up this stuff pretty well, and I like the organization better, at least currently. Now reading up about functions and prototyping and think that's great.
|
|
LazBro
Prolific Poster
Posts: 10,278
|
Post by LazBro on Jun 17, 2021 12:33:05 GMT -5
I couldn't remember a lick of it now, but C++ was the language we learned in high school computer science. I remember really liking that.
Honestly considering the pay and job security for computer programmers - I know several, and while layoffs do happen, they never seem to be out of work for more than a couple weeks - along with the fact that I seemed to enjoy doing it, I sometimes wonder how the hell I ended up an English major who now works in marketing, which I hate.
|
|
ABz B👹anaz
Grandfathered In
This country is (now less of) a shitshow.
Posts: 1,989
|
Post by ABz B👹anaz on Jun 17, 2021 12:48:16 GMT -5
I couldn't remember a lick of it now, but C++ was the language we learned in high school computer science. I remember really liking that.
Honestly considering the pay and job security for computer programmers - I know several, and while layoffs do happen, they never seem to be out of work for more than a couple weeks - along with the fact that I seemed to enjoy doing it, I sometimes wonder how the hell I ended up an English major who now works in marketing, which I hate.
Yeah. I mean, I have a lot of concerns about being a potential beginning programmer in my mid 40s. I know plenty of people start over in new careers later in life, but still...I'm worried. But I've been getting into deeper and deeper Excel formulas for years, and at some point they're basically a programming language in themselves... We'll see if I can get past the basic level in this one. I got stuck in Python when I tried to continue on my own, but not sure if that was an ACTUAL stuck or just being too lazy to study it in more depth. As it is now, I'm a week ahead in my programming class.
|
|
ABz B👹anaz
Grandfathered In
This country is (now less of) a shitshow.
Posts: 1,989
|
Post by ABz B👹anaz on Jun 17, 2021 22:14:45 GMT -5
BLEH, I went to Codeacademy to check out their C++ courses, and they're a paid site now. *spits*
|
|
ABz B👹anaz
Grandfathered In
This country is (now less of) a shitshow.
Posts: 1,989
|
Post by ABz B👹anaz on Jun 18, 2021 13:29:07 GMT -5
Okay, might as well post this here because it's aggravating me and I'm not sure what the problem is, if it's a typo somewhere, or a problem with the data file itself, or what?
This program is supposed to read input from a data file (rainfall.dat) and print it, line by line:
===============================
// This program displays a table of July rainfall totals for several // American cities. It calls a function to read the data from a file // one line at a time. The data values are stored in reference // parameters so they can be seen and used by the main function. #include <iostream> #include <string> #include <fstream> #include <iomanip> using namespace std;
// Function prototype bool readData(ifstream &someFile, string &city, double &rain);
int main() { ifstream inputFile; string city; double inchesOfRain; // Display table headings cout << "July Rainfall Totals for Selected Cities \n\n"; cout << " City Inches \n"; cout << "________________ \n"; // Open the data file inputFile.open("rainfall.dat"); if (inputFile.fail()) cout << "Error opening data file.\n"; else { // Call the readData function // Execute the loop as long as it is found and read data while (readData(inputFile, city, inchesOfRain) == true) { cout << setw(11) << left << city; cout << fixed << showpoint << setprecision(2) << inchesOfRain << endl; } inputFile.close(); } return 0; }
// readData - Each time it is called, this function reads the next // one line of data from the input file passed to it. It stores // the input data in reference variables. Then, if it read data, // it returns true. If there was no more data in the file to read, // it returns false. bool readData(ifstream &someFile, string &city, double &rain) { bool foundData = someFile >> city >> rain; return foundData; }
===============================
The data file, rainfall.dat, includes this information:
Chicago 3.70 Tampa 6.49 Houston 3.80
When I try to compile this program, I get this error:
error: cannot convert 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} to 'bool' in initialization
I have a vague idea that it is confused converting an input stream into a boolean value, but I'm not sure how to FIX this problem. Anyone?
|
|
|
Post by Jimmy James on Jun 18, 2021 13:38:11 GMT -5
Okay, might as well post this here because it's aggravating me and I'm not sure what the problem is, if it's a typo somewhere, or a problem with the data file itself, or what? This program is supposed to read input from a data file (rainfall.dat) and print it, line by line: =============================== // This program displays a table of July rainfall totals for several // readData - Each time it is called, this function reads the next // one line of data from the input file passed to it. It stores // the input data in reference variables. Then, if it read data, // it returns true. If there was no more data in the file to read, // it returns false. bool readData(ifstream &someFile, string &city, double &rain) { bool foundData = someFile >> city >> rain; return foundData; } =============================== The data file, rainfall.dat, includes this information: Chicago 3.70 Tampa 6.49 Houston 3.80 When I try to compile this program, I get this error: error: cannot convert 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} to 'bool' in initialization I have a vague idea that it is confused converting an input stream into a boolean value, but I'm not sure how to FIX this problem. Anyone? This change
bool readData(ifstream &someFile, string &city, double &rain) { bool foundData = (bool)(someFile >> city >> rain); return foundData; }
will explicitly convert your input stream to a boolean- it makes the code compile on my machine at least. An explanation given here suggests this is necessary due to changes in compilers that may have been implemented after your textbook was written.
StackOverflow (where I linked the answer from) is a good resource for solving a lot of problems of this nature- often a google search of your compiler error will lead you to someone who has encountered the same problem.
|
|
ABz B👹anaz
Grandfathered In
This country is (now less of) a shitshow.
Posts: 1,989
|
Post by ABz B👹anaz on Jun 18, 2021 13:40:37 GMT -5
This change
bool readData(ifstream &someFile, string &city, double &rain) { bool foundData = (bool)(someFile >> city >> rain); return foundData; }
Perfect, thank you so much! So frustrating when the textbook itself has an error.
|
|
|
Post by WKRP Jimmy Drop on Jun 22, 2021 22:45:59 GMT -5
BLEH, I went to Codeacademy to check out their C++ courses, and they're a paid site now. *spits* Wait are you sure? I think it’s still only pay for “pro”. I just logged in & chose a C++ class & it didn’t ask for a card.
|
|
ABz B👹anaz
Grandfathered In
This country is (now less of) a shitshow.
Posts: 1,989
|
Post by ABz B👹anaz on Jun 23, 2021 0:09:37 GMT -5
BLEH, I went to Codeacademy to check out their C++ courses, and they're a paid site now. *spits* Wait are you sure? I think it’s still only pay for “pro”. I just logged in & chose a C++ class & it didn’t ask for a card. I started a C++ class, and it gave me like two pages of lessons before saying "Congrats, now do the Pro course!" and had no other content.
|
|
|
Post by WKRP Jimmy Drop on Jun 23, 2021 21:44:30 GMT -5
Wait are you sure? I think it’s still only pay for “pro”. I just logged in & chose a C++ class & it didn’t ask for a card. I started a C++ class, and it gave me like two pages of lessons before saying "Congrats, now do the Pro course!" and had no other content. Noooooooooooo that’s where I was attempting to do my JavaScript & I really liked the setup.
|
|
ABz B👹anaz
Grandfathered In
This country is (now less of) a shitshow.
Posts: 1,989
|
Post by ABz B👹anaz on Jun 29, 2021 9:53:47 GMT -5
So far I like C++ quite a bit, and am having no major issues understanding it... ...but I DO have an issue with our professor not having graded last week's assignment before our next one was due, so we now have about a week and a half without any feedback from him whatsoever...that's not a good sign in an 8-week course. At least two of us have emailed him as well (one on Friday, me yesterday) to ask about it and received no response either. EDIT - He replied, apologized to everyone for grading the assignments but forgetting to release the grades in Canvas. I got my second A+.
|
|
Crash Test Dumbass
AV Clubber
ffc what now
Posts: 7,058
Gender (additional): mostly snacks
|
Post by Crash Test Dumbass on Jun 29, 2021 10:11:28 GMT -5
Playing with Google Script (based on JavaScript) has reminded me that I hate what I do not understand, and what I do not understand is arrays.
|
|
ABz B👹anaz
Grandfathered In
This country is (now less of) a shitshow.
Posts: 1,989
|
Post by ABz B👹anaz on Jun 29, 2021 10:22:48 GMT -5
Playing with Google Script (based on JavaScript) has reminded me that I hate what I do not understand, and what I do not understand is arrays. I understand basic 1-dimensional and 2-dimensional arrays. I have yet to wrap my head around anything more complex than that.
|
|
ABz B👹anaz
Grandfathered In
This country is (now less of) a shitshow.
Posts: 1,989
|
Post by ABz B👹anaz on Jul 1, 2021 15:32:02 GMT -5
Jean-Luc Lemur - Uh oh, do I need to be concerned about arrays?? They start at address 0 in my limited programming experience...
|
|
|
Post by Dr. Rumak on Jul 1, 2021 16:10:47 GMT -5
ABz B👹anaz They only start at 1 in Julia, which isn’t really widely used outside of certain accounting and scientific applications. Some versions of BASIC also start at 1 (including the version that was included on the Apple II+ I first learned programming on).
|
|
ABz B👹anaz
Grandfathered In
This country is (now less of) a shitshow.
Posts: 1,989
|
Post by ABz B👹anaz on Aug 4, 2021 9:11:02 GMT -5
So my C++ course is over! I got straight A+'es on my first 5 assignments, but the sixth and the final project I won't get to see grades until the instructor posts them to the college.
I had a slight amount of trouble with the sixth assignment before figuring it out, and I know I met all of the requirements for an A+, so I'm good there.
For the final project, in the last (less than full) week of class, we had to jump into object-oriented programming. Since the entire bulk of the class up to that point was function programming, it was a pretty big change in focus. I ended up reading my textbook for parts of two days, and then spending the ENTIRE Saturday the final was due in my office working in it, THIRTEEN HOURS (with a break for lunch when my family came in to visit). If it weren't for the help of one of my classmates a few times, I would have panicked and flunked the entire thing. As it is, I managed to get the requirements for a C on the final done, and was working on the B-level ones but wasn't finished, when I realized it was 10:45pm, and the assignment was due by Midnight, and I was just...done. So I did the math, realized a C on the final would mean I still get an A in the class, and just turned in what I had.
Then yesterday, I had a bit of downtime at work, so I went back and spent one more hour on the project and completed it! Solely to prove that I could. So yeah, that was actually fun!
I have access to the e-textbook for 2-3 more months, so I'm planning to read a few more chapters before then, at least until my Fall classes start overwhelming me.
EDIT - OH, I already have a follow-up course on this planned in my degree track - CISP 400, "Object Oriented Programming with C++"! Nice!
|
|