Results 1 to 6 of 6

Thread: What is the Difference between Class and Object?

  1. #1
    Join Date
    Feb 2009
    Posts
    10

    What is the Difference between Class and Object?

    Hi,

    What is the Difference between class and object?

    Regards,

  2. #2
    Join Date
    Jan 2009
    Posts
    38

    Re: What is the Difference between Class and Object?

    An object is an instance of a class.

    Such that, if class is:
    class MyClass {
    public:
    int x;
    };

    Than an object would be:
    int main()
    {
    MyClass my_object;
    }

  3. #3
    Join Date
    May 2008
    Posts
    115

    Re: What is the Difference between Class and Object?

    A Class is static. All of the attributes of a class are fixed before, during, and after the execution of a program. The attributes of a class don't change. The class to which an object belongs is also (usually) static. If a particular object belongs to a certain class at the time that it is created then it almost certainly will still belong to that class right up until the time that it is destroyed. An Object on the other hand has a limited lifespan. Objects are created and eventually destroyed. Also during that lifetime, the attributes of the object may undergo significant change.

  4. #4
    Join Date
    May 2008
    Posts
    2,389

    Re: What is the Difference between Class and Object?

    Class is a template(type) or blue print its state how objects should be and behave. eg consider a construction plan which is a class with this description mentioned in a plan we can constructs 'n' number of buildings of same type.
    these buildings are consider to be an objects come under same type of that plan. Object is defined as a software construct which binds data
    and logic or methods(functions)together.

    In short: Class is templet for an object.Object is an instance of a class.

  5. #5
    Join Date
    Feb 2008
    Posts
    1,852

    Re: What is the Difference between Class and Object?

    An object is a software bundle of related state and behavior. Software objects are often used to model the real-world objects that you find in everyday life. This lesson explains how state and behavior are represented within an object, introduces the concept of data encapsulation, and explains the benefits of designing your software in this manner.

    A class is a blueprint or prototype from which objects are created. This section defines a class that models the state and behavior of a real-world object. It intentionally focuses on the basics, showing how even a simple class can cleanly model state and behavior.

  6. #6
    Join Date
    Jan 2008
    Posts
    1,521

    Re: What is the Difference between Class and Object?

    Let us consider the class car. Cars have a body, wheels, an engine, seats, are used to transport people between locations, and require at least one person in the car for it to move by its own power. These are some of the attributes of the class - car - and all members that this class has ever or will ever have share these attributes.

    The members of the class - car - are objects and the objects are individual and specific cars. Each individual car has a creation date (an example of an object having an attribute that is static), an owner, a registered address (examples of attributes that may or may not change), a current location, current occupants, current fuel level (examples of attributes that change quickly), and it may be covered by insurance (an example of an attribute that may or may not exist).

    To use a more programming related example, the class window has edges, a title bar, maximize and minimize buttons, and an area to display the window contents. A specific window has a location on the screen, a size, a title, and may or may not have something in the content area.

    So basically the difference between a class and an object is that a class is a general concept while objects are the specific and real instances that embody that concept. When creating an object oriented program we define the classes and the relationships between the classes. We then execute the program to create, update, and destroy the objects which are the specific realization of these classes.

Similar Threads

  1. Replies: 6
    Last Post: 06-06-2011, 01:34 AM
  2. What is the difference between Local class and global class in C++?
    By Dëfrim in forum Software Development
    Replies: 4
    Last Post: 03-01-2011, 10:44 PM
  3. Debug class and Trace class Difference
    By Amaresh in forum Software Development
    Replies: 5
    Last Post: 22-01-2010, 10:00 AM
  4. Difference among concrete class and abstract class
    By Roxy_jacob in forum Software Development
    Replies: 4
    Last Post: 07-12-2009, 01:22 PM
  5. Class Object in C++
    By paintbox in forum Software Development
    Replies: 0
    Last Post: 25-10-2008, 01:13 PM

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
  •  
Page generated in 1,714,128,165.96512 seconds with 17 queries