C++ fast

download C++ fast

If you can't read please download the document

description

C++ summary

Transcript of C++ fast

Comprehensive C++ Tutorial for Beginners - Part 1Hi there. If you do not know me (you probably do not), my nickname is AzureFenrir, and this tutorial is *supposed* to teach you the basics of C++. Just promise not to sue me if it doesn't accomplish its purpose, capiche ?So you want to learn to program C++? Great! C++ is a powerful language that can be used to make anything from basic to really advanced multimedia programs. But...before you can use such a great tool, you have to know how to use it!*Insert reader groans here*Hey, didn't I tell you not to call your lawyer? You didn't? Good boy! That's one less lawsuit for me today .Anyway, the basic C++ syntax is still best illustrated by the *trumpet roll* HELLO WORLD! program. As banal and clich s it sounds, HELLO WORLD is relatively easy to dissect and probably easy for a first-time programmer to grasp.So, open your C++ compiler, and type in the following phrase:#include What does this do? It adds the "bells, whistles, and other stuff" that you need to type stuff into a DOS window and accept more stuff from the user.Now, type in the following after the #include line:int main(){cout bReturns a value of true (1) if a is larger than b. Returns false (0) otherwise.a < bReturns a value of true (1) if a is smaller than b. Returns false (0) otherwise.a >= bReturns a value of true (1) if a is larger than or equal to b. Returns false (0) otherwise.a 5);Remember bool variables from Part 1 of this tutorial? This code will store the value false (0) in temp, because 3 is not larger than five!!! (Well, maybe in other planets/dimensions, but we're talking about earth, our dimension).However,temp = (7 > 5);Will store true (1) in temp, because 7 IS greater than five. How fun was that?READER: ZzzzzzzzzzzzzzzzzzAnyway, (Wake Up!) Boolean structures are used in many different ways in C++. In this tutorial, we will discuss the selection structures - basically, the if structures, the else structure, the switch structure, and the break statement. Don't worry, this is a beginners' tutorial, which means I'll walk you through these statements step-by-step.The "if" StructureThe if structure is analogous to RM2K's FORK statements. Basically, it allows you to run a piece of code if it's conditions are met - that is, if it's inner code returns true (1).You can use it like this:if(condition){Insert what happens if the conditions are met here}Here's an example:#include int main(){int ATARIAge = 0;// Again, no offense meant to ATARIcout > ATARIAge;if(ATARIAge < 18){cout