Talk about video games, put up incredible polls, and go insane


    Basics of C++

    Poll

    Did this helped?

    [ 2 ]
    Basics of C++ I_vote_lcap67%Basics of C++ I_vote_rcap [67%] 
    [ 1 ]
    Basics of C++ I_vote_lcap33%Basics of C++ I_vote_rcap [33%] 

    Total Votes: 3
    GroupZero
    GroupZero
    Admin
    Admin

    Male
    Number of posts : 572
    Age : 24
    Description : I'm You!
    Reputation : 8505
    Registration date : 2009-02-25

    Basics of C++ Empty Basics of C++

    Post  GroupZero on Fri Oct 09, 2009 7:34 pm

    =The skeleton of a c++ program=

    #include < iostream > //include statements goes here
    using namespace std; //using statements goes here, std = standard
    const int num=1; //declare any constant variables here
    int main() //the main function of a program
    {
    //declare any variables if needed
    /* this is the main body of a program, this is where you want to put all of your coding for your program, between the {}s, by the way, put it before the statement return 0.
    */

    return 0;
    }

    #include < iostream > - it tells the compiler to include the file, there is a difference between <> and “” like “stdafx.h” in vc++. You don’t have to put include statements into stdafx.h, but it makes the main cpp file less messy. <> tells the compiler to look into the main library for the header file. “” tells the compiler to include the header file where your cpp file is stored.

    using namespace std; - so you don’t have to use the std:: prefix when you want to use cout, endl, ect. It makes your life easier.

    const – declare a constant variable, I never const, since I don’t see a point in it, but const variables’ data never changes. If it is 1, it stays 1 throughout the program.

    int main() {} - the main function of your program. This is the brain of your program, all of your coding goes in between the brackets.

    return 0; - returns a 0 to the function to end the program. You can return whatever value you like, you can even return one million. If you return a value other than a 0, it means that the program ended because of an error instead of a normal termination.

    ; tells the compiler this is the end of a command.

    ----------------------------------------------------------------------------------------------------------

    =Variable Type That You’ll Use=
    int var; - declares a variable called var, since its int, so it won’t take any decimals
    double var; - declares a variable called var, double means real number
    long double var; - same as double var; statement, but it can store a larger number
    char var; - a variable to store a character
    string var; - a variable to store more than one character, you can also use arrays

    ----------------------------------------------------------------------------------------------------------

    Note: don’t ever declare variables that have the same name like what I did, or it will give you some kind of error, unless if you declare it in another function, which you will learn later on.

    A simple Hello World program

    #include < iostream >
    using namespace std;

    int main()
    {
    cout << “Hello World”;
    system(“pause”);
    return 0;
    }

    cout – a function used to output statements
    << - tells the computer to throw string Hello World inside the “”s to the cout
    system(“pause”); - pause the program at certain line, I personally gets annoyed by the Press enter to continue or something like that. I use getchar(), it’s a bit more typing if you use it, but it doesn’t have the press whatever crap.


    Ok now, let’s get familiar with the input command cin (I don’t pronounce cin as c-in, I pronounce it as sin, like that button on your calculator)

    #include
    using namespace std;

    int main()
    {
    int a; //a variable to store the input
    cout << “Enter a number: “; //a prompt line to tell the user to input a num
    cin >> a; // inputs the num the user enters to variable a
    cout << “You entered: “ << a; // outputs the number the user had entered
    system(“pause”);
    return 0;
    }

    If it is kinda hard to read, then download the word document instead http://www.mediafire.com/file/ylzj4wammqn/basics.docx


    Last edited by GroupZero on Tue Oct 13, 2009 5:13 pm; edited 1 time in total


    _________________
    War Is The New Peace
    Basics of C++ 116q5av
    Linkmaster123
    Linkmaster123
    Moderator
    Moderator

    Male
    Number of posts : 867
    Age : 24
    Description : WILL WORK FOR AWESOME NINJA POWERS
    Reputation : 8834
    Registration date : 2009-02-25

    Basics of C++ Empty Re: Basics of C++

    Post  Linkmaster123 on Tue Oct 13, 2009 11:08 am

    SUPER HAPPY MEGA ULTRA EXTREME FUN TIME!!!!!!!!!!!!!!!!!!!


    _________________
    Basics of C++ Thfail-2
    GroupZero
    GroupZero
    Admin
    Admin

    Male
    Number of posts : 572
    Age : 24
    Description : I'm You!
    Reputation : 8505
    Registration date : 2009-02-25

    Basics of C++ Empty Re: Basics of C++

    Post  GroupZero on Tue Oct 13, 2009 3:45 pm

    Linkmaster123 wrote:SUPER HAPPY MEGA ULTRA EXTREME FUN TIME!!!!!!!!!!!!!!!!!!!
    Hey, don't break the rules. I'm not joking.


    _________________
    War Is The New Peace
    Basics of C++ 116q5av
    Linkmaster123
    Linkmaster123
    Moderator
    Moderator

    Male
    Number of posts : 867
    Age : 24
    Description : WILL WORK FOR AWESOME NINJA POWERS
    Reputation : 8834
    Registration date : 2009-02-25

    Basics of C++ Empty Re: Basics of C++

    Post  Linkmaster123 on Wed Oct 21, 2009 4:46 pm

    well than! Ashamed


    _________________
    Basics of C++ Thfail-2
    Goreblood
    Goreblood
    Admin
    Admin

    Male
    Number of posts : 1313
    Age : 23
    Description : (-)(|\)(|||)(\/)(///)(//)(-)(|\/|)(-|-)(|\|)(-|-)(///)(|\|)
    Reputation : 9262
    Registration date : 2009-02-25

    Basics of C++ Empty Re: Basics of C++

    Post  Goreblood on Thu Oct 22, 2009 9:02 pm

    My answer is yes and no. Yes for understanding some of the core roots and stuff. But no because of what EXACTLY to DO and how to put it IN. And it lacks some good scenerio examples.

    You could've put a lot more detail into each one, it's too short. I needs to explain as much as possible.

    But you did have that "touch" of explainablity. So that's why it helped me get C++ lol. But it did not help me in otherwise scenerios. You should make another topic about how to run the program to use to start off making consule programs and such.

    That's my constructive critiscm.


    _________________
    Basics of C++ Av28027

    Sponsored content

    Basics of C++ Empty Re: Basics of C++

    Post  Sponsored content

      Similar topics

      -

      Current date/time is Thu Sep 19, 2019 8:42 am