Thread: OOP and Classes Help

  1. #1
    Registered User
    Join Date
    Jun 2004
    Posts
    10

    OOP and Classes Help

    I'm very new to C++ and I am having trouble understanding what Object Orientated means and what classes are and what they do.

    I would be really grateful if someone could help me to understand these things.

  2. #2
    Registered User
    Join Date
    Mar 2002
    Posts
    1,595
    Here's my 2 cents worth:

    In real life objects have certain attributes: color, names, parts, size, weight, etc. and can do certain things: speak, run, turn, display, etc. Classes and structs allow you to incorporate those attributes and activities associated with a given object in your code. Each instance of a class or a struct is called an object and, hence, the term OOP. In real life as well as in OOP, different objects can be related to one another through inheritance (for example a dog class may inherit all the attributes of an animal class) or inclusion (for example both car and engine are objects but the car has an engine (usually)).

    Object oriented coding also helps you be more precise in coding which frequently helps you find bugs in code at compile time when it is easier to fix and it allows you to protect data from unexpected changes among other helpful features.

    These features of OOP can be very useful or may be absolutely worthless to you in a given program; so you use them when needed and forget about them when you don't.

  3. #3
    Registered User
    Join Date
    Jun 2004
    Posts
    10
    So each 'object' has certain attributes, and a class lets me use those attributes with something else?

  4. #4
    Toaster Zach L.'s Avatar
    Join Date
    Aug 2001
    Posts
    2,686
    A class just says what attributes an object has, and what actions it can perform. An object, on the other hand, is an instance of a class, with the attributes set to actual values, and actually able to perform those specified actions.

  5. #5
    Registered User
    Join Date
    Jun 2004
    Posts
    14
    a simple understanding is a ball... the class would say a ball is round, it has a color, a weight... the object would be that fould ball you caught at the red sox game, another object is the kick ball your kid is playing with outside.

  6. #6
    Registered User
    Join Date
    Jun 2004
    Posts
    10
    Ah thank you. Now I should be able to understand these tutorials a bit better.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. OOP flu
    By Hussain Hani in forum General Discussions
    Replies: 15
    Last Post: 06-27-2009, 02:02 AM
  2. OOP Question DB Access Wrapper Classes
    By digioz in forum C# Programming
    Replies: 2
    Last Post: 09-07-2008, 04:30 PM
  3. Data Mapping and Moving Relationships
    By Mario F. in forum Tech Board
    Replies: 7
    Last Post: 12-14-2006, 10:32 AM
  4. classes and oop confusion
    By ssjnamek in forum C++ Programming
    Replies: 7
    Last Post: 11-27-2003, 10:08 AM
  5. Questions on Classes
    By Weng in forum C++ Programming
    Replies: 2
    Last Post: 11-18-2003, 06:49 AM