help with a class

can someone explain or give me a good example of a class and how it works, thnx
There is some great articles/tutorials on classes on this website.

You can think of a class as a template in a sense. Ive not done nothing with classes in C++ as im still learning the language, but i have used classes in PHP and they are similar.

A real life use of a class could be a class to manage users on a system (create, amend, remove etc).

In PHP i have used them when creating forums and shopping carts for the web.

If your class isn't static, then you can create any number of objects from that class.

Your best bet is to read up on it because there is alot to learn about classes. It might be easier to learn from a book that isn't language specific, although some language may implement classes slightly different. I have a head first book from orielly that goes into detail with OOP.
Last edited on
Another way to think of a class is as a representation of a real-life object. You could create a Person class, which could hold their name, age, height, etc.

You could then have a class which 'inherits' the Person class. For example, you could create a Soldier class which inherits Person. Then, the Soldier class would automatically have the properties of Person (ie. name, age, height) and then you could add ones specific to the Soldier class, such as their rank.
Topic archived. No new replies allowed.