Learning C++

Discussion in 'Coding' started by Saiboogu, May 9, 2014.

  1. Saiboogu
    Offline

    Saiboogu Reality continues to ruin my life Council Member

    Messages:
    658
    CZs Received:
    189
    Trophy Points:
    88
    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.
     
    • Like Like x 1
  2. Saiboogu
    Offline

    Saiboogu Reality continues to ruin my life Council Member

    Messages:
    658
    CZs Received:
    189
    Trophy Points:
    88
    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 -- Capture.PNG
     
  3. PsychoAco
    Offline

    PsychoAco WAY STATUS: LOST Triumvir

    Messages:
    313
    CZs Received:
    137
    Trophy Points:
    88
    Blasphemy
     
    • Funny Funny x 1
  4. Supplice
    Offline

    Supplice He who flatters his superiors, betrays them. Council Member

    Messages:
    1,021
    CZs Received:
    121
    Trophy Points:
    308
    Old dogs can learn new tricks? Whhhhaaaatttttttt!
     
    • Like Like x 1
    • Optimistic Optimistic x 1
  5. Saiboogu
    Offline

    Saiboogu Reality continues to ruin my life Council Member

    Messages:
    658
    CZs Received:
    189
    Trophy Points:
    88
    Hey, I'm not taking a piss on vim - just setting a goal: learn C++ ;)

    I'll set a vim goal some other time.
     
  6. Saiboogu
    Offline

    Saiboogu Reality continues to ruin my life Council Member

    Messages:
    658
    CZs Received:
    189
    Trophy Points:
    88
    Well aren't I just a fancy bastard.
     

    Attached Files:

  7. Gorian
    Offline

    Gorian everybody do the flop! Council Member

    Messages:
    472
    CZs Received:
    92
    Trophy Points:
    73
  8. Saiboogu
    Offline

    Saiboogu Reality continues to ruin my life Council Member

    Messages:
    658
    CZs Received:
    189
    Trophy Points:
    88
    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.
     
  9. Supplice
    Offline

    Supplice He who flatters his superiors, betrays them. Council Member

    Messages:
    1,021
    CZs Received:
    121
    Trophy Points:
    308
    The last EXE I made was TotesNotARAT.exe, if that counts for anything.
     
  10. Saiboogu
    Offline

    Saiboogu Reality continues to ruin my life Council Member

    Messages:
    658
    CZs Received:
    189
    Trophy Points:
    88
    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.
     
    • Like Like x 1
  11. Sandbag
    Offline

    Sandbag Wanna buy a watch? Council Member

    Messages:
    739
    CZs Received:
    182
    Trophy Points:
    88
    tehehe pascal
     
    • Like Like x 1
    • Agree Agree x 1
  12. Saiboogu
    Offline

    Saiboogu Reality continues to ruin my life Council Member

    Messages:
    658
    CZs Received:
    189
    Trophy Points:
    88
    Doing my homework. Capture.PNG
     
    • Like Like x 1
  13. PsychoAco
    Offline

    PsychoAco WAY STATUS: LOST Triumvir

    Messages:
    313
    CZs Received:
    137
    Trophy Points:
    88
    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
     
    • Like Like x 1
  14. Saiboogu
    Offline

    Saiboogu Reality continues to ruin my life Council Member

    Messages:
    658
    CZs Received:
    189
    Trophy Points:
    88
    I knew I was wording that wrong

    sent from the nexus
     
  15. PsychoAco
    Offline

    PsychoAco WAY STATUS: LOST Triumvir

    Messages:
    313
    CZs Received:
    137
    Trophy Points:
    88
    I mean it does the same thing, but it is just bad syntax.

    Sent from my Nexus 7 using Tapatalk
     
  16. Saiboogu
    Offline

    Saiboogu Reality continues to ruin my life Council Member

    Messages:
    658
    CZs Received:
    189
    Trophy Points:
    88
    Yeah. It ran but I was getting a warning on that line.

    sent from the nexus
     
  17. Saiboogu
    Offline

    Saiboogu Reality continues to ruin my life Council Member

    Messages:
    658
    CZs Received:
    189
    Trophy Points:
    88
    I keep posting to keep myself working, but critiques welcome. This is all real entry level practice work.

    Capture.PNG

    Capture.PNG

    Loops and more loops Capture.PNG
     
    Last edited: May 16, 2014
  18. Saiboogu
    Offline

    Saiboogu Reality continues to ruin my life Council Member

    Messages:
    658
    CZs Received:
    189
    Trophy Points:
    88
    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";
    
    }
    Capture.PNG
     
  19. Gorian
    Offline

    Gorian everybody do the flop! Council Member

    Messages:
    472
    CZs Received:
    92
    Trophy Points:
    73
    good to see you are forming good habits and using int main() instead of void main() which is incorrect, but still taught sometimes >.<
     
    • Like Like x 2
  20. Saiboogu
    Offline

    Saiboogu Reality continues to ruin my life Council Member

    Messages:
    658
    CZs Received:
    189
    Trophy Points:
    88
    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
     
    • Like Like x 2
Loading...