Basics of C++ - WIP

Discussion in 'Archives' started by Raid500, Aug 16, 2009.

Basics of C++ - WIP
  1. Unread #1 - Aug 16, 2009 at 9:03 PM
  2. Raid500
    Joined:
    Feb 11, 2007
    Posts:
    592
    Referrals:
    1
    Sythe Gold:
    0

    Raid500 Forum Addict

    Basics of C++ - WIP

    Raid's C++ Tutorial WORK IN PROGRESS

    Hey everyone, I like c++ very much, it's 1 of my favorite languages to use because of the capabilities with it.C++ is a lot like c and java. In this guide I will explain a lot of the basic things of c++ and hopefully by the time you read the whole guide, you will have learned something.

    Chapter 1: Compiler
    Chapter 1.1: C++ Compiler
    Well in order to compile and run your files made in c++ you will need to get a compiler. I would recommend getting Dev-C++. You can of course try many different compilers and see how you like each 1, I'm just giving you the 1 I use.

    Chapter 1.2: Getting to know your compiler
    There are a few buttons you will need to know in order to use your compiler. Locate your compile button, run button, save button, and new button. Once you know where those are your set.



    Chapter 2: Basics
    Chapter 2.1: #include (Header)
    Whenever you see #include <SOMETHING> it is telling the compiler to use the declaration from that certain file. The most common you will see is #include <iostream>. For most math programs (calculators with trig functions and square roots) #include <math.h> and for most windows programs (Like programs that search computers ie virus scanners) #include <windows.h>

    Chapter 2.2: Cout and cin
    The cout statement is what you put before you would like something to be displayed when you run your program. Look at the following bit of code: (Note: this is just a small code it will not work if put into a compiler)

    << is output this(this means whatever is after it)
    >> is input this(this means whatever you type in)

    Code:
    int a;
    cout << "What is 1+1?" << endl;
    cin >> a;
    if(a==2)
    cout << "Correct!" << endl;
    if(a!=2)
    cout << "Sorry you're wrong :(" << endl;
    
    Line 1: int a This is where the integer would be stored, once it is said in the program, the compiler will remember what you said.
    Line 2: Cout and endl Cout is just what the compiler displays, you must have << after cout. the endl is just something to make the program look nicer (the spacing)
    Line 3: Cin is what you will be inputting and making the compiler save.
    Rest of the lines: If statement, a lot like java, if something is true, then this will happen, if not then this will happen or nothing will happen.

    Chapter 2.3: Operators
    Operators are pretty basic and most are the same. Java, c++, and php operators are all the same. The only ones that people may have problems with are % (Modulo), which I don't even know why you would use and that's why I'm not even going to explain it, if you are interested in learning it I suggest googling it.
    &&: You can use this to say if 2 things are true (or false) to say that.
    Example:

    Code:
    cout << "What are the square roots of 9?";
    cin >> x;
    if(x==3 && -3)
    cout << "TRUE!";
    
    ||: This is the or operator you can say if this OR this happens then this will (or won't) happen
    Example:

    Code:
    cout << "Who is cool?";
    cin >> x;
    if(x==Raid)
    cout << "TRUE!";
    
    Chapter 2.4: Arrays - 7/31/09
    Arrays are similar to ints, but holds more data.

    Code:
    int runetrinity[3] = { 1, 2, 3 }; //3 in the array
    cout << runetrinity[2]; //prints the 2nd number in the array.
    
    You can add mathematical things to arrays also, like..
    Code:
    int runetrinity [2][3]; //multiply the 2nd and 3rd values in the array runetrinity
    int runtrinity [6]; //the result of the above
    
    Chapter 2.5: If Conditional - 7/31/09
    As you saw above I used a if statement which is the same as a lot of other languages. In normal words it's like if this happens then this will happen otherwise this happens, kinda confusing so lets look at an example.

    Code:
    if(raid==online) //if I am online
    cout << "Raid is online!"; //output will be this
    else //otherwise
    cout << "Raid is offline :("; //output will be this
    
    Else if is used for more than 1 thing, not sure how to put this lol
    Code:
    if(raidspost > 100) //if my posts are greater than 100
    cout << "Very nice!"; //this will show up
    else if(raidspost < 100) //my posts are less than 100
    cout << "noob !!"; //i is nub :(
    
    Work In Progress



    Enjoy,
    Raid




    WILL BE UPDATED PROBABLY WILL TAKE A WHILE FOR THE WHOLE GUIDE!


    Note: If you find any errors report them to me :)
     
  3. Unread #2 - Sep 12, 2009 at 5:40 PM
  4. 29range
    Joined:
    Nov 12, 2008
    Posts:
    339
    Referrals:
    0
    Sythe Gold:
    0

    29range Forum Addict

    Basics of C++ - WIP

    Wow, thanks, like the way you set it out, a joy to read. So far I'd say 6/10 because I think you need to go further in depth.

    Good luck finishing it!
     
  5. Unread #3 - Sep 26, 2009 at 9:01 PM
  6. war833
    Joined:
    Dec 11, 2008
    Posts:
    82
    Referrals:
    0
    Sythe Gold:
    0

    war833 Member

    Basics of C++ - WIP

    An array can old any data type, not just ints like this implies.
     
  7. Unread #4 - Nov 26, 2009 at 9:45 AM
  8. hiway_2_hell
    Joined:
    Nov 26, 2009
    Posts:
    230
    Referrals:
    0
    Sythe Gold:
    0

    hiway_2_hell Active Member
    Banned

    Basics of C++ - WIP

    very helpfull guide
     
  9. Unread #5 - Mar 28, 2010 at 1:31 AM
  10. EhProtect
    Joined:
    Feb 18, 2010
    Posts:
    52
    Referrals:
    0
    Sythe Gold:
    0

    EhProtect Member
    Banned

    Basics of C++ - WIP

    Doesn't cover the basics for the newbies to C++. Very poorly written.
     
  11. Unread #6 - Jun 19, 2010 at 1:31 PM
  12. blindkilla
    Joined:
    Jun 22, 2005
    Posts:
    1,896
    Referrals:
    0
    Sythe Gold:
    6
    Discord Unique ID:
    282000633404456960
    Discord Username:
    sogord

    blindkilla Guru
    $25 USD Donor New

    Basics of C++ - WIP

    A lot of mistakes in this guide.
     
< Hookups' UE Application. | Tgump >

Users viewing this thread
1 guest


 
 
Adblock breaks this site