Results 1 to 15 of 15
  1. #1
    HypnoticBabeTrap's Avatar
    Join Date
    Dec 2009
    Gender
    male
    Posts
    35
    Reputation
    10
    Thanks
    28

    C++ Learning TUT BIG!

    OK guys well I will be teaching you C++ over time you will learn from this. I will be adding more and more and more as I feel the need you have Grasped the concept. So let's start



    One of the hardest things about learning a programming language is the fact that no element exists in isolation. Rather, the components of the language work without involving another. To help overcome this problem, this chapter Chaper 1.. lol provides a brief overview of seceral core C++ features, including the general form of a C++ program, some simple control statements, variables, and operators. It does not go into too many details, but rather concentrates on the general concepts common to all C++ programs. Most of the topics presented here are examined more closely in later chapters.

    Since learning is best accomplished by doing, it is recommended that you work through the example using your computer.

  2. #2
    HypnoticBabeTrap's Avatar
    Join Date
    Dec 2009
    Gender
    male
    Posts
    35
    Reputation
    10
    Thanks
    28

    Your first C++ program

    Before getting into any theory, let's look at a simple C++ program. We will start by entering, compiling, and running the following program.

    Code:
    /* Program #1 - A first C++ program.
    
    Enter this program, then compile and run it.
    */
    
    #include <iostream>
    using namespace std;
    
    // main() is where program execution begins.
    int main()
    {
    cout << "This is my first C++ program.";
    
    return 0;
    }
    You will follow these steps.

    1. Enter the program.
    2. Compile the program.
    3. Execute the program.

    Before beginning, it is necessary to fedine two terms. The first is source code. Source code is the version of your program that humans can read. :P The preceding listing is and example of source code. The executable version of your program is called object code or executable code. Objeect code is created by the compiler when it compiles your pgoram.

  3. #3
    HypnoticBabeTrap's Avatar
    Join Date
    Dec 2009
    Gender
    male
    Posts
    35
    Reputation
    10
    Thanks
    28

    Entering the Program

    Typing the programs yourself often helps you remember the key concepts.

    The name of the file that holds the source code for the program is technically arbitary. However, C++ programs are normally contained in files that use the file extension .cpp. thus, you can call a C++ program file by any name, but it should use the .cpp extension. For this example, call the source file MyProgramOwns.cpp so that you can follow along. For most of the other programs in this tut , simply use a name of your own choosing.

  4. The Following User Says Thank You to HypnoticBabeTrap For This Useful Post:

    Gwinx (12-30-2009)

  5. #4
    HypnoticBabeTrap's Avatar
    Join Date
    Dec 2009
    Gender
    male
    Posts
    35
    Reputation
    10
    Thanks
    28

    Compiling the program

    How you will compile MyProgramOwns.cpp depends upon your compiler, and what options you are using. Furthermore, many compilers, such as Microsoft's Visual C++ and Borland's C++ builder, provide two different ways for compiling a program: the command line compiler and the Integrated Development Environment (IDE). Thus, It is not possible to give generalized instructions for compiling a C++ program that will work for all compilers. You must consult your compiler's instructions.

    The preceding paragraph not withstanding, two of the most popular compilers are Visual C++ and C++ builder. For the benefit of readers using one of these compilers, the easiest way to compile and run the programs in this tut is to the use the command-line compilers offered by these environments, and that is the method described.

    To comple MyProgramOwns.cpp using Visual C++, you will use this command line.

    C:\...>cl -GX MyProgramOwns.cpp

    The -GX option enhances compilation. To use the visual C++ command-line compiler, you must first execute the batch file VCVARS32.BAT, which is provided by Visual C++. (You will want to consult your visual C++ documentation for details.)
    To compile MyProgramOwns.cpp using C++ builder, use this command line

    C:\...>bcc32 Sample.cpp

    The output from a C++ compiler is executable object code. For a windows environment, the executable file will use the same name as the source file, but have the .exe extension. Thus, The executable version of MyProgramOwns.cpp will be in MyProgramOwns.cpp.exe.

  6. The Following User Says Thank You to HypnoticBabeTrap For This Useful Post:

    Gwinx (12-30-2009)

  7. #5
    HypnoticBabeTrap's Avatar
    Join Date
    Dec 2009
    Gender
    male
    Posts
    35
    Reputation
    10
    Thanks
    28

    Run the Program

    After a C++ program has been compiled, It is ready to be run. Since the output from a C++ compiler is executable object code, to run the program, simply enter its name at the command prompt. For example, to run MyAwesomeProg.exe use this command line:

    C:\...>MyAwesomeProg

    When run, The program displays the following output.

    This is my frist C++ program.

    If you are using an Integrated Development Environment, then you can run a program by selecting Run from a menu. Consult the instructions for your specific compiler. As mentioned earlier, for the programs in this tut, it is usually easier to compile and run from the command line.

    One last point: The programs in this tut are console-based, not window-based.
    That is, they run in a Command Prompt session. C++ is completely at home with Windows programming. Indeed, it is the most commonly used language for Windows development. However, none of the programs in this tut use the Windows Graphics User Interface(GUI). The reason for this easy to understand: Windows is a complicated environment to write programs for, involving many side issues unrelated to the C++ language. In contrast, Console-based programs are much shorter and are the type of programs normally used to teach programming. One you have mastered C++, you will be able to apply your knowledge to Windows programming with no trouble

  8. The Following User Says Thank You to HypnoticBabeTrap For This Useful Post:

    Gwinx (12-30-2009)

  9. #6
    HypnoticBabeTrap's Avatar
    Join Date
    Dec 2009
    Gender
    male
    Posts
    35
    Reputation
    10
    Thanks
    28

    A line-by-line explanation

    Now that you have successfully compiled and run the first sample program it is time to understand how it works. towards this end, we will examine the program line by line. The program begins with the lines

    /* Program #1 - A first C++ program.

    Enter this program, then compile and run it.
    */

    This is a comment. Like most other programming languages, C++ lets you enter a remark into a program's source code. The contents of a comment are ignored by the compiler. The purpose of a comment is to describe or explain the operation of a program to anyone reading its source code. In the case of this comment, it identifies the program. In more complex programs, you will use comments to help explain what each features of the program is for now and how it goes about doing its work. In other words, You can use comments to provide a "play By Pay" description of what your program does.

    In C++, there are two types of comments. The one you've just seen is called a multiline comment. This type of comment begins with a /* and ends with only a */ Anything between these two comment symbols is completely ignored by the compiler. Multiline comments may be one or more lines long. The second type of comment is found a little further on in the program; we'll be discussing it shortly.

    The next line of code looks like this:

    #include <iostream>

    The C++ language defines several headers, which contain information that is either necessary or useful to you program. For this program, the header <iostream> is needed.(it is used to support the C++ I/O system.) This header is provided with your compiler. A header is included in your program by using the #include directive. Later in this tut, You will learn more about headers and why they are important.

    The next line in the program is

    using namespace std;

    This tells the compiler to use the std namespace. Namespaces are a relatively recent addition to C++. Although namespaces are discussed in detail later in this tut, here is a brief description. A namespace creates a declarative region in which various program elements can be placed. Elements declared in one namespace are separate from elements declared in another. Namespaces help in the organization of large programs. The using statement informs the compiler that you want to use the std namespace. This is the namespace in which the entire Standard C++ library Is declared. By using the std, you simplify access to the standard library.

    The next line in the program is

    // main() is where program execution begins.

    This line shows you the second type of comment available in C++: the single=line comment. Sing-line comments begin with // and stop at the end of the line. Typically, C++ programmers use mulltiline comments when writing larger, more detailed commentaries, and they use single-line comments when short remakrs are needed. However, this is a matter of personal style

  10. The Following User Says Thank You to HypnoticBabeTrap For This Useful Post:

    Gwinx (12-30-2009)

  11. #7
    Lolland's Avatar
    Join Date
    Feb 2009
    Gender
    male
    Location
    Lolland!
    Posts
    3,156
    Reputation
    49
    Thanks
    868
    My Mood
    Inspired
    Lol can you not post frequently and maybe just edit your first post?

  12. The Following User Says Thank You to Lolland For This Useful Post:

    crushed (12-25-2009)

  13. #8
    HypnoticBabeTrap's Avatar
    Join Date
    Dec 2009
    Gender
    male
    Posts
    35
    Reputation
    10
    Thanks
    28

    A line-by-line explanation Cont.

    The next line, As the preceding comment indicates, is where program execution begins:

    int main()

    All C++ programs are composed of one or more functions. (Loosely speaking, a function is a subroutine.) Every C++ function must have a name, and the only function that any C++ program must include is the one shown here, called main(). the Main() function is where program execution begins and (most commonly)Ends. (Technically speaking, a C++ program begins with a call to main()and, in most cases, ends when main() returns.) The opening curly brace on the line that follow mains() marks the start of the main() function's code. The int that precedes main() specifies the type of data returned by main(). As you will learn, C++ supports several built in data types and int is one of them. It stands for Integer.

    The next line in the program is

    cout << "this is my frist C++ program.";

    This is a console output statement. It causes the message This is my first C++ program. to be displayed on the screen. It accomplishes this by using the output operator <<. the << operator causes whatever expression is on its right side to be output to the device specified on its left side. cout is predefined identifier that sstands for console output, which (most generally) refers to the computer's screen.
    This, this statement causes the message to be output to the screen. Notice that this statement ends with a semicolon. In fact, all C++ statements end with a semicolon.

    The message "this is my first C++ program." is a string. In C++ , a string is a sequence of characters enclosed between double quotes. As you will see, strings are used frequently in C++.

    The next line in the program is

    return 0;

    This line terminates main() and causes it to return the value 0 to the calling process (which is typically the operating system(, for most operating systems a return value pf 0 signifies that the program is terminating normally. other values indicate that the program is terminating because of some error. return is one the C++'s keywords, and it is used to return a value from a function. AL;l of your programs should return 0 when they terminate normally(that is, Without error).

    The closing curly brace at the end of the program formally concludes the program Although the brace is not actually part of the object code of the program, conceptually you can think of a C++ program ending when the closing curly brace of main() is executed. In fact, if the return statement were not part of this sample program, the program would automatically end when the closing curly brace was encountered.

  14. The Following User Says Thank You to HypnoticBabeTrap For This Useful Post:

    Gwinx (12-30-2009)

  15. #9
    crushed's Avatar
    Join Date
    Oct 2009
    Gender
    male
    Location
    My name is Jay. k?
    Posts
    415
    Reputation
    10
    Thanks
    113
    My Mood
    Sneaky
    *sigh*. You see that knife by your mouse, yeah, well either stab me ion the eyes, or yourself. There's an edit button RIGHT there, seriously man. lol

    I don't mind you trying to help, but doing it over 20 posts is only going to piss people off.

    EDIT: Oh look, I just used it just to say, that you should add a TOC, references you used. Otherwise you're going to be flamed for being a C+P'er. And, *sigh* if you say you wrote all of it yourself, then all I have to say is, where did you learn it from?. Few pointers.

    And, btw. Here's what I mean unless you are too busy ignoring what everyone is saying. Kinda like how you ignored Lolland.
    https://www.mpgh.net/forum/31-c-c/103...whar-i-dl.html

    But I guarantee, that you'll completely ignore this post.

    EDIT: Lol Why, now I see what you mean.

    Quote Originally Posted by why06 View Post
    Well they've been doing it long before you allowed them too... Oh well. Like father, like son o_O. I still gotta read all of this to be honest it may not be worth sticking since 99.9% of the nubs that run through don't bother to read.
    Oh well, Hell_Daddy, whenever you're ready.
    Last edited by crushed; 12-25-2009 at 05:47 PM.

  16. #10
    Hell_Demon's Avatar
    Join Date
    Mar 2008
    Gender
    male
    Location
    I love causing havoc
    Posts
    3,976
    Reputation
    343
    Thanks
    4,320
    My Mood
    Cheeky
    Well done, you managed to explain the simpleness of 'Hello World'!
    Where other people, and even C++ books spend 5-10 lines of text on it, you manage to spend 7 posts on it, and even after those 7 posts noone will bother to read it since its fucking simple 'Hello World' app that isn't even worth learning...
    Ah we-a blaze the fyah, make it bun dem!

  17. The Following 2 Users Say Thank You to Hell_Demon For This Useful Post:

    crushed (12-26-2009),Matrix_NEO006 (12-27-2009)

  18. #11
    BxR.'s Avatar
    Join Date
    Dec 2009
    Gender
    male
    Posts
    51
    Reputation
    10
    Thanks
    0
    lol increasing your post rate much?

  19. #12
    Void's Avatar
    Join Date
    Sep 2009
    Gender
    male
    Location
    Inline.
    Posts
    3,198
    Reputation
    205
    Thanks
    1,445
    My Mood
    Mellow
    Quote Originally Posted by BxR. View Post
    lol increasing your post rate much?
    I see you're doing the same.

  20. #13
    BxR.'s Avatar
    Join Date
    Dec 2009
    Gender
    male
    Posts
    51
    Reputation
    10
    Thanks
    0
    Quote Originally Posted by Davidm44 View Post
    I see you're doing the same.
    and now so are you xD

  21. #14
    why06's Avatar
    Join Date
    Jul 2009
    Gender
    male
    Location
    IBM
    Posts
    4,304
    Reputation
    170
    Thanks
    2,203
    My Mood
    Flirty
    Hmmmm... what to do?

    Most of this is unnecessary, but at the same time I can't dog you for the effort. I'll to think about it when its not 3:30 A.M.
    Sorry I've been scarce the last few days, I always seem to be extremely busy over vacations. =/

    "Every gun that is made, every warship launched, every rocket fired signifies, in the final sense, a theft from those who hunger and are not fed, those who are cold and are not clothed. This world in arms is not spending money alone. It is spending the sweat of its laborers, the genius of its scientists, the hopes of its children. The cost of one modern heavy bomber is this: a modern brick school in more than 30 cities. It is two electric power plants, each serving a town of 60,000 population. It is two fine, fully equipped hospitals. It is some fifty miles of concrete pavement. We pay for a single fighter plane with a half million bushels of wheat. We pay for a single destroyer with new homes that could have housed more than 8,000 people. This is, I repeat, the best way of life to be found on the road the world has been taking. This is not a way of life at all, in any true sense. Under the cloud of threatening war, it is humanity hanging from a cross of iron."
    - Dwight D. Eisenhower

  22. #15
    rwkeith's Avatar
    Join Date
    Jul 2008
    Gender
    male
    Posts
    457
    Reputation
    11
    Thanks
    79
    My Mood
    Angelic
    I wouldnt blame someone for bumping a thread after putting their time into it. Shouldn't be too hard on the guy.
    Goals In Life:
    [X] Become an Advanced Member
    [X]Release a tut on mpgh
    [0]Post 300 posts
    [X]Make a working hack
    [X] Learn c++

Similar Threads

  1. [Tut] Big Bang Training Spots
    By antonmoskalev in forum MapleStory Tutorial & Guides
    Replies: 10
    Last Post: 01-09-2011, 08:12 AM
  2. BIG NOOB here please help learn coding
    By brysonlee in forum C++/C Programming
    Replies: 25
    Last Post: 05-07-2010, 12:28 PM
  3. Learn Hacks for Games & Systems! TUTS!
    By bug_NOT_ME in forum General Hacking
    Replies: 1
    Last Post: 09-12-2009, 11:23 AM
  4. C++ Tut Videos [Helpful whoeva wants to learn C++]
    By GOD in forum Programming Tutorials
    Replies: 3
    Last Post: 04-29-2009, 01:47 PM
  5. Tut Getting vb and learning the basics
    By nlowner in forum Visual Basic Programming
    Replies: 3
    Last Post: 08-03-2007, 04:05 PM