Closed Thread
Results 1 to 7 of 7

Thread: Classes, Methods, and Objects

  1. #1
    Sionofdarkness is offline Programming Expert
    Join Date
    Jul 2006
    Posts
    383
    Rep Power
    0

    Classes, Methods, and Objects

    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.

  2. CODECALL Circuit advertisement
    Join Date
    Always
    Posts
    Many

     
  3. #2
    Join Date
    Jul 2006
    Posts
    16,491
    Blog Entries
    75
    Rep Power
    143
    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().
    Programming is a branch of mathematics.
    My CodeCall Blog | My Personal Blog

  4. #3
    Sionofdarkness is offline Programming Expert
    Join Date
    Jul 2006
    Posts
    383
    Rep Power
    0
    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!

  5. #4
    Join Date
    Jul 2006
    Posts
    16,491
    Blog Entries
    75
    Rep Power
    143
    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.
    Programming is a branch of mathematics.
    My CodeCall Blog | My Personal Blog

  6. #5
    Sionofdarkness is offline Programming Expert
    Join Date
    Jul 2006
    Posts
    383
    Rep Power
    0
    Oh, now I get it (at least, a little more).

  7. #6
    Join Date
    Jul 2006
    Posts
    16,491
    Blog Entries
    75
    Rep Power
    143
    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.
    Programming is a branch of mathematics.
    My CodeCall Blog | My Personal Blog

  8. #7
    Sionofdarkness is offline Programming Expert
    Join Date
    Jul 2006
    Posts
    383
    Rep Power
    0
    Each time you respond, I understand more and more.

Closed Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Classes and Methods... Pseudo Code
    By wolfman in forum General Programming
    Replies: 0
    Last Post: 10-19-2011, 12:40 AM
  2. learning classes and objects
    By jackson6612 in forum C and C++
    Replies: 20
    Last Post: 10-01-2011, 01:44 AM
  3. Replies: 2
    Last Post: 04-10-2011, 07:58 AM
  4. Objects and Classes
    By josh in forum C Tutorials
    Replies: 4
    Last Post: 04-14-2010, 04:55 AM
  5. Replies: 5
    Last Post: 08-25-2009, 10:52 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts