C++ Tutorial Ok first of all I would like to say that I DID - TopicsExpress



          

C++ Tutorial Ok first of all I would like to say that I DID NOT WRITE THIS However I found it in some OLD backups of disks Ive found and thought I would share this. This is a GREAT beginner tutorial and it can also be used as a reference for experts... This is VERY long 20 lessons tutorial, but that one is the best Ive seen in the internet thats why you will see the first 2 lessons on our fanpage: Lesson 1 - The Basics This tutorial is designed for everyone: even if youve never programmed before or if you have extensive experience programming in other languages and want to expand into C++! It is for everyone who wants the feeling of accomplishment from a working program. Getting set up: C++ is a programming language of many different dialects, similar to the way that each spoken language has many different dialects. In C++, dialects are not because the speakers live in the North or South. Instead, it is because there are many different compilers that support slightly different features. There are several common compilers: in particular, Borland C++, Microsoft C++, and GNU C++. There are also many front-end environments for the different compilers--the most common is Dev-C++ around GNUs G++ compiler. Some, such as G++, are free, while others are not. Please see the compiler listing for more information on how to get a compiler and set it up. Each of these compilers is slightly different. Each one should support the ANSI/ISO standard C++ functions, but each compiler will also have nonstandard functions (these functions are similar to slang spoken in different parts of a country). Sometimes the use of nonstandard functions will cause problems when you attempt to compile source code (the actual C++ written by a programmer and saved as a text file) with a different compiler. These tutorials use ANSI/ISO standard C++ and should not suffer from this problem (with sufficiently modern compilers). Note that if you are using an older compiler, such as TCLite, you should read check out some compatability issues. If you dont have a compiler, I strongly suggest that you get one. A simple compiler is sufficient for our use, but make sure that you do get one in order to get the most from these tutorials. The page linked above, compilers, lists compilers by operating system. C++ is a different breed of programming language. A C++ program begins with a function, a collection of commands that do something. The function that begins a C++ program is called main; this function is always called when the program first executes. From main, we can also call other functions whether they be written by us or by others. To access a standard function that comes with the compiler, you include a header with the #include directive. What this does is effectively take everything in the header and paste it into your program. Lets look at a working program: Code: #include using namespace std; int main() { cout> reads a value into thisisanumber; the user must press enter before the number is read by the program. cin.ignore() is another function that reads and discards a character. Remember that when you type intput into a program, it takes the enter key too. We dont need this, so we throw it away. Keep in mind that the variable was declared an integer; if the user attempts to type in a decimal number, it will be truncated (that is, the decimal component of the number will be ignored). Try typing in a sequence of characters or a decimal number when you run the example program; the response will vary from input to input, but in no case is it particularly pretty. Notice that when printing out a variable quotation marks are not used. Were there quotation marks, the output would be You Entered: thisisanumber. The lack of quotation marks informs the compiler that there is a variable, and therefore that the program should check the value of the variable in order to replace the variable name with the variable when executing the output function. Do not be confused by the inclusion of two separate insertion operators on one line. Including multiple insertion operators on one line is perfectly acceptable and all of the output will go to the same place. In fact, you must separate string literals (strings enclosed in quotation marks) and variables by giving each its own insertion operators (
Posted on: Sat, 16 Nov 2013 12:09:48 +0000

Trending Topics



Recently Viewed Topics




© 2015