Hey. I've been learning the basics of classes and have learned:
declaration and function implementation of classes
object instantiation: constructors and destructors
member variable and functions: public vs private, set/get functions
passing objects to functions
object composition
I understand the concepts and can write code to perform them, but when I try and practice, I cannot figure out when to use classes. Could someone shed some light on this? Thanks.
Why? A class is used to describe real-world objects. What objects can you describe in a game? The main character, monsters, vehicles, weapons, etc.... It depends on your imagination!
Start from a gaming perspective and very soon, you'll expand your horizons to knowing where to use classes. In fact, classes are used in almost EVERY program to describe almost anything.
functions are pieces of codes that you will execute multiple times. a class is used to represent:
a) data types (for example me and IWishIKnew are working on a class for representing binary strings)
b) ast's (dont worry about it. just felt like making this as complete as possible)
c) exceptions (for try-catch blocks)
d) a container (std::vector, std::string, std::list)
You can check this out: http://gameprogrammingpatterns.com/index.html
You can find useful programming patterns there, and maybe when you see how they work, you'll know when to use them, and when not.
Cheers!