I have been trying to learn classes for a week but I just cannot seem to understand them

I hav been reading up on classes for about a week now, and I understand the syntax (pretty) well, but I just cannot figure out what they can be used for. I have read about them on this website, on the book I am reading (Practical Programming C++), as well as watched youtube vides (thenewboston, etc.). With the exceptions of the examples that these have used, I cannot see a use for classes, and I know they are of extreme importance.

For example, say a Pokemon type game was made in C++, would each of the pokemon have a class? Or would there be a class "Monster", which has every pokemon in it? What are some other, practical examples for what classes could be used for? Also, I am making a tic-tac-toe game. How could classes be implemented there? Would there be an X class and an O class?
They exist for your convenience; to make it easier for you to think about how to solve a given problem, and to make it easier for you to think about how to write that solution programatically.

There is no absolute "this MUST be a class and that MUST NOT be". The most common approach I've seen is that if if makes it easier for you to think of something as a discrete object that should take care of its own internals, then it might be sensible to make it a class. If you're going to have lots of different thingies of the same type, then making that type a class would be very sensible.

This is about how you think about solving problems. Sometimes making classes is sensible, sometimes it isn't.

In your example, if there are lots of pokemon objects, then it would seem sensible to make a pokemon class, and then each pokemon is a separate instance of that class. I know this is sensible because in the mental picture I am using to solve the problem, I have lots of pokemon objects; they're all pokemon, and they all have different states and internal values.

Would there be an X class and an O class?

Can you think of a good reason for that? What internal values would these objects have? What internal states would you have them take care of for themselves?
Topic archived. No new replies allowed.