Category: 

What Is a Class Array?

Article Details
  • Written By: Eugene P.
  • Edited By: Angela B.
  • Last Modified Date: 04 September 2016
  • Copyright Protected:
    2003-2016
    Conjecture Corporation
  • Print this Article
Free Widgets for your Site/Blog
Built at the request of Dag Hammarskj√∂ld, the United Nations Headquarters has a meditation room dedicated to silence.   more...

October 1 ,  1890 :  Yosemite National Park was established.  more...

In object oriented computer programming, a class array can refer to one of two types of data structures. Some programmers use the term to describe a standard array data type made up of elements that are object instances of a given class. It also can be an encapsulated object of the class array, also known as a wrapper object, used in place of a scalar array to make a variety of methods available for use in managing the array. Although there might be more complex functionality, the wrapper array class is really no different in concept than wrapper objects for other scalar data types such as integers or characters. In both cases, the structure can only be used within the context of an object oriented programming language that supports classes.

Ad

The first definition of a class array identifies it as a standard array data type that is declared to hold objects instantiated from a single specific class. This is commonly done when holding a set series of objects, especially when the maximum number of objects is known so the array is not declared with an excessive amount of elements. The polymorphic mechanisms in object oriented programming means the use of a class array can be very dynamic, because it can hold a generic superclass, allowing a variety of subclasses to be held as elements despite their varying implementations. One complication when using a class array, however, can arise when the number of elements is unknown and either grows larger than the defined size of the array, or is very small, leaving wasted memory space allocated with the array. A solution is to use collection-type objects such as vectors or arraylists instead of a scalar array that cannot be resized.

The second definition of a class array is an object that contains a scalar array but also provides a number of methods to manipulate and change the array. Some languages implement very efficient sorting and searching algorithms within a class array wrapper. Another advantage in using an array that is implemented as a class is that the class can easily be passed and changed by different functions and methods, especially if the base array class is descended from a generic object class. The class array is often the basis for other types of array-based classes in a programming library, such as an arraylist or a hash table. Additionally, some languages allow the array class to be extended, meaning a user can redefine some of the basic methods with more specialized implementations while retaining the core functionality of the class.

Ad

You might also Like

Recommended

Discuss this Article

Post your comments

exception 'Exception' with message 'error writing captcha: Duplicate entry '2147483647' for key 'PRIMARY'' in /ssd/www/wisegeek/public_html/_core/classes/public/Captcha.php:44
Stack trace:
#0 /ssd/www/wisegeek/public_html/_core/controls/public/ControlDiscussionPostBox.php(324): Captcha->createCaptcha()
#1 /ssd/www/wisegeek/public_html/framework/classes/Control.php(104): ControlDiscussionPostBox->preRender(false)
#2 /ssd/www/wisegeek/public_html/framework/classes/Control.php(149): Control->render()
#3 /ssd/www/wisegeek/public_html/tpl/default-nocustom-lu/pages/public/article/article.htm(526): Control->__toString()
#4 /ssd/www/wisegeek/public_html/framework/classes/Control.php(300): require('/ssd/www/wisege...')
#5 /ssd/www/wisegeek/public_html/framework/classes/Control.php(309): Control->requireTpl('pages/public/ar...', Object(PageArticleCom), true)
#6 /ssd/www/wisegeek/public_html/framework/classes/Control.php(131): Control->renderTpl('pages/public/ar...', Object(PageArticleCom))
#7 /ssd/www/wisegeek/public_html/framework/classes/FormDataControl.php(87): Control->renderTemplate()
#8 /ssd/www/wisegeek/public_html/framework/classes/Control.php(109): FormDataControl->renderTemplate()
#9 /ssd/www/wisegeek/public_html/framework/classes/ScriptPage.php(50): Control->render(false)
#10 /ssd/www/wisegeek/public_html/framework/classes/Control.php(149): ScriptPage->render()
#11 /ssd/www/wisegeek/public_html/framework/classes/Page.php(97): Control->__toString()
#12 /ssd/www/wisegeek/public_html/_core/classes/public/PublicFrontController.php(443): Page->processRequest()
#13 /ssd/www/wisegeek/public_html/_core/classes/public/PublicFrontController.php(7): PublicFrontController->renderPage()
#14 /ssd/www/wisegeek/public_html/index.php(11): PublicFrontController::run()
#15 {main}