So UE4 has gotten me seriously excited to try jumping into some programming. I've wanted to really learn some fundamentals of programming for awhile but didn't pursue it. As it stands now I know syntax - the terms and language itself - for PHP, HTML, some Perl, few other random things. What I'm not good with are the bigger concepts like Object Oriented Programming, Model-View-Controller, Classes, etc. Just some things I've seen tossed around as core concepts that I've never really learned or used. So, UE4... Big fancy engine, pretty easy to access and use, seems like some decent opportunities to make money on it.. Maybe it's time to get started. So I did some Googling around for the best way to learn C++ (UE4's language) from scratch and found as many opinions as there are games in King's Steam library. So, I picked something that looked reputable and I'm jumping in with the cprogramming.com introductory tutorial. I'll post some updates here -- self motivation of sorts.
Day One. Got my IDE (Code::Blocks) setup. I also saw tutorials that used anything from MS Visual Studio to vim on the linux command line, but Code::Blocks was a very popular choice, it's free & lightweight, and if I did something like the vim route I'd wind up spending days getting up to speed on vim, tweaking my environment, etc. The point isn't to learn vim, it's to learn C++ -- So I picked the quickest path to the code. I can branch out later. Time to start the first lesson. IDE works --
Hey, I'm not taking a piss on vim - just setting a goal: learn C++ I'll set a vim goal some other time.
I'll stay the course for now on cprogramming.com - also got the ebook that goes along with, since I spend half the evening burried in my Kindle already. Edit -- But I'll keep that in mind if I get stuck on a concept. Good to get another perspective. Gotta say, there's something just kinda awesome about creating my own EXE.
Maybe, if I had a clue what that was about. I've compiled AutoHotkey scripts into EXEs before, but I don't really count that. Compiled some Pascal stuff back in the mid 90s. Though maybe they were COMs, heh.
At line 16, you don't need beer = beer--; You can just have beer--; beer-- assigns the value of beer - 1 to the variable beer. Sent from my Nexus 7 using Tapatalk
I keep posting to keep myself working, but critiques welcome. This is all real entry level practice work. Loops and more loops
I'm certain I overcomplicated this one, but it got the job done. Code: #include <iostream> #include <string> using namespace std; int main() { string question, choice1, choice2, choice3; int tally1 = 0, tally2 = 0, tally3 = 0, selection = 0, sum = 0; int graph1 = 0, graph2 = 0, graph3 = 0, graph = 0; cout << "Enter your poll question: "; getline( cin, question, '\n'); cout << "\n"; cout << "Enter choice #1: "; getline( cin, choice1, '\n'); cout << "\n"; cout << "Enter choice #2: "; getline( cin, choice2, '\n'); cout << "\n"; cout << "Enter choice #3: "; getline( cin, choice3, '\n'); do { cout << string(5, '\n'); cout << question << "\n"; cout << "1. " << choice1 << "\n"; cout << "2. " << choice2 << "\n"; cout << "3. " << choice3 << "\n"; cout << "\n"; cout << "Make your selection by number: "; cin >> selection; cout << string(5, '\n'); switch ( selection ) { case 1: tally1++; cout << "Selection recorded, thank you."; break; case 2: tally2++; cout << "Selection recorded, thank you."; break; case 3: tally3++; cout << "Selection recorded, thank you."; break; case 0: cout << "Polling complete, thanks."; break; default: cout << "Invalid choice, try again"; break; } } while ( selection != 0 ); cout << string(5, '\n'); sum = tally1 + tally2 + tally3; graph1 = ((tally1*10)/sum); graph2 = ((tally2*10)/sum); graph3 = ((tally3*10)/sum); graph = graph1 + graph2 + graph3; cout << "Results: \n"; cout << sum << " total votes.\n"; cout << "[" << string ( graph1, '#') << string ( graph-graph1, '-' ) << "] " << choice1 << " " << tally1 << "\n"; cout << "[" << string ( graph2, '#') << string ( graph-graph2, '-' ) << "] " << choice2 << " " << tally2 << "\n"; cout << "[" << string ( graph3, '#') << string ( graph-graph3, '-' ) << "] " << choice3 << " " << tally3 << "\n"; }
good to see you are forming good habits and using int main() instead of void main() which is incorrect, but still taught sometimes >.<
Now that I've read the functions chapter I bet void main came from the MS crowd. Exit codes aren't something I ever considered before *nix sent from the nexus