Alright I give up, you are all so needy to learn C++ so I and hopefully others here will try and teach you. The plan is I'll try and post once per day and througout the day try and answer questions. I have a few things to say before we get started

First, I'm not a C++ god, I will make mistakes, and I'm perfectly happy to take corrections written in English, and in a kind tone.

Second, I will do my best to answer questions but I'm counting on other people here to help me out as well.

Third, get a book, it is all well and good to follow along here, and I hope I can pass some knowledge to you, but you are going to want to have something solid to flick through to remind you of library functions, and unusual syntax.

I think that's it though I do reserve the right to add more things to this list as we go on.

Lesson 1
OMGWTF HOW DU I MAKEZ GAMEZ!!!!

Ok I am going to assume you have a compiler of some sort, and have a readme to go with your compiler that tells you how to use it. I am also going to assume you know the difference between source code(what you will be writing), and machine code(the application that is run), and that is about it, so for you with more experience you might want to check back in in a few days.Alright enough assumtions lets talk structure.

C++ has a pretty simple structure, heres a quick walkthrough of what our first few programs will look like:

Precompile Directives
this means these things get done before the compiler gets to your code.
Declarations
Strictly speaking this isn't nesscary in C++, but it just makes good sense to declare things at the top.
main
For now all our programs are going to have a main loop here
Defintions
This is where you put your define what you declared

And that is it, not alot to it, we'll start expanding our structure as we go along but for now lets focus on Precompile Directives. Most of what goes here is "#include" commands, these commands are used to include different files that have code that we haven't written, for now we are going to use code from the standard library of C++ code.

Heres an approximation of what code will look like:

precompile directives

declarations
main
{
instructions
}
definitions

note that I added the two curly braces {}, and "instructions" in them, instructions is a generic term for anything that is not a declaration, a precompile directive, or a definition. Instructions are almost always surrounded by curly braces, and they either are followed by a semi-colon (;) or another pair of curly braces {}. Instructions are the heart of programming, basically they work like instructions in the real world, like this:

main ()
{
read_on;
}

The instructions you send to a computer work the same way, they just have to be in the computer's memory. To add instructions to it's memory we either have to write them ourselves, or we can load a header file and include it's code, to do that we use the "#include " preprocessor directive. We use the .h extension to indicate that the file is a header file, different from the .cpp files we will code in.


//These double slash marks allow me to add comments that are ignored by the compiler
//get in the habit of using them, for now use them on every line of code
//put in questions, and information about each line. remember though as soon as you hit
//return you have to put another set of slashes to comment again

#include //here we include the iostream header fileextension

int main() //for now it is enough to know that this marks the starting point of your program
{
cout << "HI MOM!"; //here you can see we have an instruction, we'll be using this quite a bit
return 0; //here we have a special instruction, this one ends our main function
}


Alright well the above code is a basic program, before I sign off for the night, I want to talk a little about the cout line, basically what the instruction does is print whatever is in the quotes, go ahead and try altering it.

We've covered basic structure of the program, talked about the #include directive, touched on the main function, and introduced an instruction, not bad for a first lesson, I know I know, half of you have probably done this, but you have to learn structure, tomorrow I promise something more fun.
• L34rn teh C++ Lesson 1 - 20030904.031842 - Cunbelin
• L34rn teh C++ Lesson 2 - 20030904.035220 - Cunbelin
• L34rn teh C++ Lesson 3 - 20030904.035626 - Cunbelin
• L34rn teh C++ Lesson 4 - 20030904.040456 - Cunbelin
• L34rn teh C++ Lesson 5 - 20030904.041016 - Cunbelin
• L34rn teh C++ Lesson 6 - 20030904.041732 - Cunbelin
• L34rn teh C++ Lesson 7 - 20030904.041913 - Cunbelin


Subnova™ and the Broken Bullseye Logo are trademarks of Subnova.
Intellectual © Subnova, 2000 - 2009.
Lots of other stuff © their respective owners.
Trademarks are property of their respective owners.
No infringement is intended.

Second Life® and Linden Lab® are trademarks of Linden Research, Inc.

This page was created in 0.749 seconds by PHP 5.2.6 using 1.50 MB on Apache/2.2.9 (Fedora).
Subnova runs on DREAMS v5 [Build: 20080730.144615].