classes

Started by
4 comments, last by markrodgers11 11 years, 6 months ago
okay so recently ive been reading a book on C++ and i've learned quite a bit and i just wanted to see what it was like so i took a look at the cryengine 3 source code that they release with the SDK. and suprisingly i could KIND OF understand it xP although at the same time alot of the stuff they made was custom so there was a lot of things i was confused about but i realized when i look at source code everyone uses classes, but for some reason the book doesnt cover classes to towards the end of the book.

So I was just wondering if someone could explain how classes work in C++ and how to use them and the syntax? Basically everything i should know about classes ;p
Advertisement
I would suggest reading THIS and THIS

Classes and Objects may seem confusing at first, but once you start using them, you'll like what they can do - they are very versatile.

I cannot remember the books I've read any more than the meals I have eaten; even so, they have made me.

~ Ralph Waldo Emerson

OK, that is a rather large bill of things to request.

Take a look at the tutorial in my sig, the coding starts in part 2, and you will see classes in action and with real world examples.

Simplest way to describe it, classes are a way of organizing your code into logical units. A class is a template or model from which objects are created ( a class is a thing, an object is an instance of a thing. For example, my car is a Hyundai Veloster. A Veloster is a class, while MY Veloster is an object ). A class can have both methods ( functions ) and variables. Access to these functions can be public, private or restricted to other classes. You can use one class to create another derived class, and this is called inheritance.

Thats the 1000 foot explanation, now go read the tutorial for actual examples.


EDIT: Added link, as if I change my sig, suddenly this post will make very little sense in the future...
okay thanks guys!
markrodgers11, the sooner you learn Classes the easier programming life becomes! Just picture programming an RPG, and you have the Enemy Class. You can use it as a template for hundreds of different enemies! It's a life saver, not to mention you can easily transfer those Classes into other projects by copying the .h and .cpp file over! If it wasn't for reusable code, I would surely go mad.
GameDev Journal: http://www.gamedev.n...-rooks-journal/

OpenChess - 1.0 done!

Classic RPG #1 - Task 9 -> January 1st 2013
yeah thats what i've heard and tahts why i wanna start learning how to use classes ;p ive been learning about vectors recently and those are pretty cool xP

This topic is closed to new replies.

Advertisement