3 Answers - Sort by: Date | Rating
Class and object both are the terminologies which are used in many programming languages.
About the class, so class is the main thing with the help of which a program is made ,if once the class is created it remains till the end of the program, we can't made another class with the same name of the previous class.
We made functions within the class and within the function we use attributes. Function name and the class name should not be the same.While the object are made with in the class and the objects time span is very less as the class finish the object is also destroyed.
Every object belongs to a class and every class contains one or more related objects.
Simply in one sentence "we made objects within the class".
To differentiate the class and object there is an example.We consider a class "car", which have many attributes like seats, wheels and engine and also have the members of the class, so these members are the objects of that class.
Class is static. The attributes of a class always remain unchanged. Class and object both are related to each other, without class, object is of no use and without object, class is useless. So both are important for each other.
About the class, so class is the main thing with the help of which a program is made ,if once the class is created it remains till the end of the program, we can't made another class with the same name of the previous class.
We made functions within the class and within the function we use attributes. Function name and the class name should not be the same.While the object are made with in the class and the objects time span is very less as the class finish the object is also destroyed.
Every object belongs to a class and every class contains one or more related objects.
Simply in one sentence "we made objects within the class".
To differentiate the class and object there is an example.We consider a class "car", which have many attributes like seats, wheels and engine and also have the members of the class, so these members are the objects of that class.
Class is static. The attributes of a class always remain unchanged. Class and object both are related to each other, without class, object is of no use and without object, class is useless. So both are important for each other.
1
0
The easiest way to explain the difference between an object and a class would be through an example.
Suppose that you created a class called Counter. This class is very simple and only contains one PRIVATE DATA MEMBER called Current Count of type unsigned int. Also, suppose that this class has two PUBLIC MEMBER FUNCTIONS. One, called Increment Count, simply increments the current value of Current Count by one. The other member function is called Return Current Count and simply returns the value of Current Count data member.
Now that you have created this class you wish to use it in your program, so that let's suppose when a button INCREMENT is pressed value of CurrentCount is incremented and when button SHOW VALUE is pressed the current value of CurrentCount is displayed.
In order to use this class you must create an object of the class in the button click function. Once an object of the class is made you can access the public functions (IncrementCount and ReturnCurrentCount ) using the dot operator.
An example of this would be:
Counter myCounter;
myCounter.IncrementCount ();
Response.write (ReturnCurrentCount());
Hence, a class is a user-defined data type. You can create your own class with data members and member functions that cater to your programming need.
But, in order to use this data type that you have created you must declare (instantiate) its object, and use the DOT OPERATOR to access its public functions.
Suppose that you created a class called Counter. This class is very simple and only contains one PRIVATE DATA MEMBER called Current Count of type unsigned int. Also, suppose that this class has two PUBLIC MEMBER FUNCTIONS. One, called Increment Count, simply increments the current value of Current Count by one. The other member function is called Return Current Count and simply returns the value of Current Count data member.
Now that you have created this class you wish to use it in your program, so that let's suppose when a button INCREMENT is pressed value of CurrentCount is incremented and when button SHOW VALUE is pressed the current value of CurrentCount is displayed.
In order to use this class you must create an object of the class in the button click function. Once an object of the class is made you can access the public functions (IncrementCount and ReturnCurrentCount ) using the dot operator.
An example of this would be:
Counter myCounter;
myCounter.IncrementCount ();
Response.write (ReturnCurrentCount());
Hence, a class is a user-defined data type. You can create your own class with data members and member functions that cater to your programming need.
But, in order to use this data type that you have created you must declare (instantiate) its object, and use the DOT OPERATOR to access its public functions.
0
0
Guest
answered 6 months ago
- How Do I Add A Column To A Table In Word 97?
- What Is A Disadvantage Of Using A Paper-based Database?
- What Is Code Of Integrity?
- How To Get Java On My Lg 260?
- How To Make A Digital Clock In C Language?
- Write A Java Program To Store A Number Find If It Is Positive Or A Negative Number If Positive Print I Am The First?
- Finds The Factorial Of The Numbers That Lie Between 1 And 10 Using Nested For Loop?
- What Is Polymorphism ? With Example
- Where Can I Find Pdf Files Of The Old White Wolf Rpg Books?
- How To Create A Header File In C Language?
- What Is Difference Between HTML Vs XHTML?
- How The Efficiency And Integrity Of The Data Is Maintained At All?
- A Form In Visual Basic Is Best Described As What?
- How To Update The Sim 3 Expansion?
- Program To Calculate Change The Name To Write In Any Word In English And It Will Convert To Change Any Language Of User?
- What Are The Risks In Undertaking A Systems Analysis And Design Activity?
- Do While Loop In C++ Output?
- What Is File-based Approach?
- What Is Cascading Rollback?
- How Do I Create An SQL Queries That Show: Student Name, Address, And Contact Information For All Students? Student Name And The Certificate Program For Which They Are Registered Student Name And The Courses For Which They Are Registered?
- I Need To Create A System Where Students Can Register For One Of 5 Certificates, Select Courses, And Obtain A Transcript Of The Grades Received For The Courses. Each Student Can Be Enrolled For Only One Certificate. There Are 4 Courses In Each Cert?
- How The Efficiency And Integrity Of The Data Is Maintained At All Times Although The Database Is Used By Varying Organisational Levels? 2 Examples
- What Is An Attribute In Java?
- How About Links Of London?
- I Am Told That In Java, Arrays Are Objects. Which Class Arrays Are Called As Objects?
- What Is The Difference Between Mutable Objects And Immutable Objects?
- What Is The Difference Between Superclass And Sub Class?
- In C++ What Is The Difference Between Object And Class?
- What Is The Difference Between Abstract Class And Abstract Method?
- What Is The Difference Between Abstract Class & Interface?
- What Is The Difference Between An Abstract Class And An Ordinary Class?
- What Is A Static Class And What Is The Difference Between Static And Instanciate?
- What Is The Basic Difference Between Structure And Class In C++?

New Comment - Comments are editable for 5 min.