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 other files with our main file, for now we are going to just include libraries.
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 library, to do that we use the "#include <library.h>" preprocessor directive. Now C++ has several different libraries ready to use, for our purposes we will be using the iostream library, lets do a little code.
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.
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 other files with our main file, for now we are going to just include libraries.
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 library, to do that we use the "#include <library.h>" preprocessor directive. Now C++ has several different libraries ready to use, for our purposes we will be using the iostream library, lets do a little code.
PHP:
//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 <iostream.h> //here we include the iostream library, library files use the .h file extension
int main() //for now it is enough to know that this marks the starting point of your program
{
cout << "piss off"; //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.