|
20080730.144615
i added amazon context links... just because i can... if they're not too obtrusive... i'll leave them
20080114.231544
enabled mod_deflate on andromeda. the site is now seeing an estimated 80% reduction in overall size for clients to download
20080109.022443
added an rss 2.0 feed for the news at http://www.subnova.com/news/rss/. it will show the 14 most recent posts
20070823.031056
updated cq calculations so that if a member doesn't login to the website in the past 77 days, the contribution points start vanishing in a hurry... tanking the irank
20070823.024814
removed the referral ads from the bottom of the main content area
[more]
|
|
|
|
|
|
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.
|
|
|
|
|
|
|
No articles have been posted in the last month.
Slackers.
|
|