answersLogoWhite

0


Best Answer

An array stores a list of values, usually of the same type. Values are distinguished by a subscript.

A class usually doesn't store objects, but it defines a template for objects. Objects based on this class store data, which can be of different types, and are distinguished by name (similar to variables). A class thus defines a new, composite, data type (so does an array, but in a more limited way).

Besides, a class can also define functions (usually called "methods"), specifically for objects of that type.

Usage example: If you want to sort 100 numbers, or do some other work with them, you might store them in an array of numbers (integers, or floating-point numbers, depending on your needs).

If, on the other hand, you want to store information about a person, you might create a class, where you define that a "person" includes information about a first name, last name, birthdate, etc.

User Avatar

Wiki User

11y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

14y ago

An array is a collection of the same type of data, for example, integers. Each element is accessed through an index - a numerical value. For example, myArray[x], where "x" is an integer variable.

An object (created from a class) can store different types of data; each is accessed through its name, for example, person.age, person.name, etc.

An object, or class, also has several other properties that distinguish it from an array; for example, classes/objects also have methods (functions defined at the class level), and with classes you can have inheritance.

This answer is:
User Avatar

User Avatar

Wiki User

14y ago

An array is a block of memory. A function is a set of lines of code.

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What is difference between array and class?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

What is the difference between numeric array and associative array?

Numeric array has numbers(+integers) that represent the values Associative array has strings that represent the values


What is the difference between array and string of array?

When we declare an array of characters it has to be terminated by the NULL , but termination by NULL in case of string is automatic.


Difference between vector and array list?

Vectors are thread safe but array lists are not. Hence array lists are faster than Vectors.


What is the difference between Land Grid Array and Pin Grid Array?

One has pin in front, one has land


What's the difference between the Class 365 and Class 465 466?

The difference between the Class 365 and Class 465, 466 is basically the cost.


Difference between exclusive or inclusive class intervals?

difference between inclusive and exclusive class interval


What is the difference between a Magician and a Chorus Line?

A Magician has a cunning array of stunts ...........................................................................


What is Difference between programmable logic array and programmable array logic?

Using and gate - pla is programmable while pal is fixed


What is difference between first class and second class on train trips?

What is the difference between buying a 1st class and a 2nd class ticket on the train in England?


Why is an array called a derived data type?

An array is not a derived data type at all. In order to be derived there has to be a base class and an array has no base class. Here is the basic declaration of the std::array template class from the <array> header file: template<class _Ty, size_t _Size> class array { // fixed size array of values // ... }; A vector, on the other hand, is derived (from the <vector> header file): template<class _Ty, class _Alloc = allocator<_Ty>> class vector : public _Vector_alloc<!is_empty<_Alloc>::value, _Vec_base_types<_Ty, _Alloc>> { // varying size array of values // ... };


What is the difference between a class What is the difference between a class III and class IV hitch and?

class III rated for up to 5,000lbs, class IV is rated for up to 10,000lbs towing capacity


Main difference between Array List and Vector in Java?

List is not sync'd as a vector is.