Game Development Community

dev|Pro Game Development Curriculum

Struggling with Learning C++? Maybe Something Helpful.

by 'Sidikian' · 06/10/2011 (12:32 am) · 4 comments

Welcome all,

And as the preview suggests you might remember awhile ago I was learning Polygon Modeling Mostly with Blender 3D and I was trying to track my journey for anyone that it could possibly help get started with that.

Well I'm back again this time to talk a little about my journey or struggle in trying to learn the programming language C++ which you most likely know is the computer language that the T3D and other Torque engines are written in.

Some years ago (not sure I care to remember how many) I bought a C++ Black Book( http://www.amazon.com/Black-Book-Comprehensive-Guide-Mastery/dp/1576107779 ) to help me learn C++. I picked it up a few times, read a little then put it down again for months and struggled as I went never really getting far enough into the book without having to restart from the begining again since it had been so long since I last looked at it.

Months, years went by and I tryed to get myself to pick up learning C++, via my book and on various different sites on the web. Still I was never able to keep up on it enough because of my lack of interest in reading or ability to focus when reading.

Well since T3D was such a good deal I'm inspired once again to make a push to get somewhere on creating my own game, thus I'm back at it again once again trying to learn C++ and recently I've found a web site that has really made some of the basics start to click for me despite my struggles with reading.

I feel as though the way the info presented is just put in a way that makes it easier to understand.
I've been following the code examples, tweaking and messing around with it and smile when my code works even though it's only been simple changes so far.

So I thought maybe someone else out there is like me and tryed to pick it up a few times but it just never clicked so I wanted to post the site url where the tutorials I'm going through are:

http://www.cprogramming.com/begin.html

NOTE: THIS IS FREE atleast as far as I've gone so far.

And here's an example of my code thus far using what was given and tweaking it a touch with notes directly taken from what is said in the tutorial and things put in my own words and as such I claim no right to any of it as to not cross any copyright laws. (Also to help you understand this code if you are new please note that anything following // or /* and */ is commented out and not read by the complier and that's where you can find the notes telling what each line of code does.):




#include <iostream> //#include is a "preprocessor" directive that tells the compiler to put code from the header called iostream

using namespace std; //This line tells the compiler to use a group of functions that are part of the standard library (std)

int main() //This line tells the compiler that there is a function named main, and that the function returns an integer
{
int thisisanumber; /*declaring the a variable thisisanumber and since int was used it will
look for a whole number to store because int is whole numbers, char looks for single character, and float
looks for numbers with decimal points i.e. 5.33324 */

cout<<"Please enter a number that is less than 10. \n";
/*again this is c-out and prints the info in the "" out or
if there are no "" it will look for a declared varible like below thisisanumber*/

cin>> thisisanumber; /* cin looks for input from the user in this case thisisanumber variable is
used thus it looks for a a whole number b/c of how int declared the variable thisisanumber*/

cin.ignore(); /* this tells the program to ingnore the enter button that the user hit to enter the number*/

cout<<"You entered: "<< thisisanumber <<"\n";/*you must separate string literals (strings enclosed in
quotation marks) and variables by giving each its own insertion operators (<<) */

if ( thisisanumber < 10) { /*if tests what's in the () in this case my declared variable from above
thisisanumber to see if it's less than 10 and if true executes the command c-out, or cout if not true it uses the else statement*/

cout<<"This number is less then 10 big surprise. ";
}

else {
cout<<"This number is not less than ten duh. ";
}

cin.get(); /*again asking for an enter press before the program closes that way you can see it worked properly instead of the program just closeing on you without your enter promt*/

/*hmm notes ok so it appears the name of the variable can be anything but how you delcare it is what type of info it stores*/
}




That little program will ask someone to enter a number less than 10 and if they do it says the number is less than 10 big surprise and if not it says this number is not less then 10 duh.

So if that got your interest go to the site and start right with the Getting Started section and I recommend using code blocks just as they suggest to "keep things simple stupid".

Also, I'm putting a shout out to all of you in the community that may know of any easy to read FREE info or video tutorials or anything on learning C++.

If you know of some video tuts or more sites or something that speaks C++ in simple, easy to understand terms, Please post a response and let us know.

And of course if any of the past info or current info I've linked has helped you any please let me know so I know whether or not I'm helping people or just annoying people with blogs like these.

So I know whether to continue them or just stop posting them.

Here's a couple other sites I've found but again nothing has seemed to help me as much as what I've mentioned above; however one site might help with particular areas more than the others so check them all out as you go if you get hung up:

-Learning to compile with Visual C++2005:
http://cplus.about.com/od/learning1/ss/clessonone.htm

-C++ Language tutorial:
http://www.cplusplus.com/doc/tutorial/introduction/

Again hope that helps get you started and as stated above if you know of other sites or tuts please post them in a reply.

Also I would of put this in a resource but Idk I guess I just didn't know if it was resource material *shrug*.

-Sid.

#1
06/12/2011 (10:55 pm)
My one friend (whom I recently talked into buying T3D) recently found another C++ site which might come in handy. I haven't had a ton of time to look over the site well but it looks promising.

Just note that it talks about using Allegro ("Allegro 4 and Allegro 5 are cross-platform, open source, game programming libraries, primarily for C and C++ developers..." -from the offical Allegro site) for the game making examples it shows.

http://www.cppgameprogramming.com/cgi/nav.cgi?page=index
#2
06/13/2011 (8:52 am)
Looks very promising. Maybe I'll actually learn something this summer..
#3
06/14/2011 (11:48 pm)
Nice... keep it up!
When I was dictating the C++ course at my university, I always told the students to use a lot of comments. Comments are a very important tool as they let you understand your code after leaving it for some time.

Also, try learning how to separate your code in libraries and how to create test cases.

Read a good OOP book, its good to pin the concepts before you start with C++.

Luck!
#4
06/15/2011 (3:37 am)
Thanks for the Tip Guimo much appreciated.