|
Post by Revan on Oct 16, 2008 13:07:18 GMT -5
I don't really have anything to do today, I'll probably make about 5 tutorials... this place will also serve to me as a reference for what I want to do when, the list that follows is most likely the order in which the tutorials will be made.
int, double, and float variable types
char and string variable types
cin
//comments
operators to variables, +=, -=, ++, --, *=, etc
boolean expressions
'if' statements
'switch' statements
'while' loops
'do while' loops
'for' loops
function usage (math.h)
function creation
function -- parameters/return types
function -- reference variables
That's a start, I'll flesh out this list later...
|
|
|
Post by m4t1a5 on Oct 18, 2008 3:04:44 GMT -5
Cool, ill need help with the functions so i hope they are done soon.... when is the first 1 coming out?
|
|
kp3
New Member
Posts: 4
|
Post by kp3 on Oct 19, 2008 7:32:11 GMT -5
When will you explain classes to retards like me?
|
|
|
Post by Revan on Oct 19, 2008 14:47:44 GMT -5
That could take a long time... however, to put it simply, a class is an object. Every object in the world has properties... for example... lets say you have a class called 'door', well a door object is likely to have a property called 'open' which would say whether or not the door was open. Now if you think about it, in real life if you want to open/close a door, you need to push it, you can't just go and say "ok you're open now", same with C++, you would make the 'door' property 'private', meaning that only the code of that class can change that variable, through a function.
Functions are also in classes, so for 'door', you may have something such as: void open(); and void close(); which would change the 'open' variable to reflect the current state of the door.
That's the basic concept.
|
|
kp3
New Member
Posts: 4
|
Post by kp3 on Oct 20, 2008 9:31:26 GMT -5
Makes sense.
Classes are in .h files right?
|
|
|
Post by Revan on Oct 20, 2008 23:15:08 GMT -5
Errr yes and no. Class declarations... ie: class door { public: Door(); void open(); void close(); void printState(); private: bool isOpen; };
Is in the .h file (not the ';' at the end of the brace for a class, you won't find one after any other brace but these)
You would then make a .cpp file with the same name as the .h one (but without the same extension of course) and that would contain: Door::Door() { isOpen = false; } void Door::open() { isOpen = true; } void Door::close() { isOpen = false; } void Door::printState() { cout << "I am: " << (isOpen ? "open" : "closed") << endl; }
Or at least I think thats where the Door:: goes... it's 12am so I may not be right however I do think that is correct. Give it a try, see if it works.
Take note of the first function, that is the constructor, it sets up your class when you make it, you can have parameters, however they aren't needed. In this case, the constructor makes certain that 'isOpen' contains a value so that if it is called before you try and open or close the door, it has something to tell you. I chose to make it closed because that is the normal state of a door.
Finally, your main could look something like this....
Door d; d.printState(); d.open(); d.printState(); d.close(); d.printState();
Which would tell you that it's closed, then opened, then closed again.
Happy coding.
|
|
|
Post by Revan on Oct 29, 2008 20:17:09 GMT -5
New tutorials by this weekend... I've got my recorder open and would be recording at this moment were it not for the new mythbusters....
|
|
|
Post by Revan on Oct 29, 2008 22:01:09 GMT -5
Unfortunately now it's a bit late... so I'll probably record the tutorial(s) tomorrow... the next thing of course is variables...
|
|
|
Post by Revan on Nov 10, 2008 21:14:57 GMT -5
I recorded two tutorials already tonight and I will be making a third in a short while... they probably won't be uploaded till Friday... but I wanted to make sure you all know that I ain't dead and neither is this tutorial series.
|
|
|
Post by Revan on Nov 24, 2008 9:14:24 GMT -5
Mk, no promises... but I'll see what I can do to get the tutorials uploaded some time before friday....
|
|
|
Post by Revan on Nov 24, 2008 21:20:59 GMT -5
Files are now compressed... hope that I find time enough to upload....
|
|
|
Post by Revan on Nov 26, 2008 8:48:11 GMT -5
Well they've been uploaded for a couple of days however revver is being dumb about copyright crap again... it should be sorted soon... hopefully.. I just hope their staff didn't take off for the holiday.
|
|