What's the difference between these three things (classes, methods, and objects). Aren't they also in C++, I think that's one of the similarities between the two languages. Well, if someone could just tell me the relationship between them, that'd be great.
Classes, Methods, and Objects
Started by Sionofdarkness, Jul 21 2006 11:23 AM
6 replies to this topic
#1
Posted 21 July 2006 - 11:23 AM
|
|
|
#2
Posted 21 July 2006 - 02:00 PM
A class is a definition of an object in an object-oriented programming language (including C++, Java, Delphi, C#, VB, and many others). For example: "A dog is a mammal in the canine family that has been domesticated" would be a class.
An object is an instance of the class. For example: Fido, Fluffy, Bruno, and Kujo are all objects of the dog class.
A method is a function that objects of a class can perform. For example: all dogs can bite(), bark(), walk(), run(), sit(), and roll_over().
An object is an instance of the class. For example: Fido, Fluffy, Bruno, and Kujo are all objects of the dog class.
A method is a function that objects of a class can perform. For example: all dogs can bite(), bark(), walk(), run(), sit(), and roll_over().
#3
Posted 22 July 2006 - 08:30 AM
Very interesting, that explained a lot. Can you also give me a real-code example, because I'm sure that's not how it works in the coding world (you know what I mean). Thanks again!
#4
Posted 23 July 2006 - 06:57 AM
In Java, everything's a class. For example, a Window has location, width, height, and you can tell it to show(), hide(), resize(x,y), move(x,y), etc. Check out Thinking in Java for plenty of examples.
#5
Posted 29 July 2006 - 09:09 AM
Oh, now I get it (at least, a little more).
#6
Posted 29 July 2006 - 11:54 AM
Classes are usually used to model things. Things have properties, such as size, location, etc., and abilities, such as moving, storing, making noise. Properties are generally called something like attributes, and abilities are called methods, which work just like functions.
#7
Posted 21 August 2006 - 09:55 AM
Each time you respond, I understand more and more.


Sign In
Create Account


Back to top









