Closed Thread
Results 1 to 4 of 4

Thread: understanding classes

  1. #1
    Chan is offline Programming Professional
    Join Date
    Jun 2006
    Posts
    205
    Rep Power
    0

    understanding classes

    I am having a very hard time understanding classes. Why would I use a class? what are they for?

  2. CODECALL Circuit advertisement
    Join Date
    Always
    Posts
    Many

     
  3. #2
    smith is offline Programmer
    Join Date
    Jun 2006
    Posts
    153
    Rep Power
    0
    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.
    Code:
    for (int i;;) {
       cout << "Smith";
    }

  4. #3
    brackett is offline Programmer
    Join Date
    May 2006
    Posts
    192
    Rep Power
    22
    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.

  5. #4
    husky44's Avatar
    husky44 is offline Learning Programmer
    Join Date
    Jun 2006
    Posts
    30
    Rep Power
    0
    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.

Closed Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 13
    Last Post: 09-09-2011, 09:18 PM
  2. Help understanding this
    By geno53 in forum General Programming
    Replies: 4
    Last Post: 01-15-2011, 08:19 PM
  3. please help in understanding the Warning
    By ahshan in forum C and C++
    Replies: 7
    Last Post: 10-01-2010, 01:31 AM
  4. understanding hex codeing.
    By DesperD0s in forum General Programming
    Replies: 4
    Last Post: 08-13-2010, 04:57 AM
  5. Need help in understanding a loop
    By lionaneesh in forum C and C++
    Replies: 1
    Last Post: 05-31-2010, 05:27 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