I am having a very hard time understanding classes. Why would I use a class? what are they for?
understanding classes
Started by Chan, Jul 14 2006 07:35 AM
3 replies to this topic
#1
Posted 14 July 2006 - 07:35 AM
|
|
|
#2
Posted 15 July 2006 - 05:30 PM
Classes are great for making OOP. You would make classes so that you can use the code again. I'm not great at explaining this though. Maybe one of the other guys can explain better.
for (int i;;) {
cout << "Smith";
}
#3
Posted 16 July 2006 - 07:12 PM
Classes are basically a way of organizing your program.
They give you public/private/protected members so that you can have different parts of your program accessible to different callers (important for security, versioning, and cleanliness).
They give you a small unit of code that can be tested, reused (though that's usually a secondary concern - classes normally don't get reused all that much. That's what libraries and components are for), and shared.
They allow you to use OOP, so that you can inherit behaivor from other classes, change behaivor at runtime, and abstract out the behaivor from callers or dependents.
More or less, they're an attempt at solving the age old complexity problem in software by encapsulating data and the methods required to work on that data into a single object. Once a single object "owns" the data and the responsibility of managing it, it can be treated as a black box in most cases.
They give you public/private/protected members so that you can have different parts of your program accessible to different callers (important for security, versioning, and cleanliness).
They give you a small unit of code that can be tested, reused (though that's usually a secondary concern - classes normally don't get reused all that much. That's what libraries and components are for), and shared.
They allow you to use OOP, so that you can inherit behaivor from other classes, change behaivor at runtime, and abstract out the behaivor from callers or dependents.
More or less, they're an attempt at solving the age old complexity problem in software by encapsulating data and the methods required to work on that data into a single object. Once a single object "owns" the data and the responsibility of managing it, it can be treated as a black box in most cases.
#4
Posted 16 July 2006 - 09:19 PM
brackett explained it perfectly there.
The way I look at it in very general terms is that a class is a thing, an object, or a task etc etc - basically one object entails one "entity" in a program.
The way I look at it in very general terms is that a class is a thing, an object, or a task etc etc - basically one object entails one "entity" in a program.


Sign In
Create Account


Back to top









