Categories
  Encyclosphere.org ENCYCLOREADER
  supported by EncyclosphereKSF

Containment (computer programming)

From HandWiki - Reading time: 1 min

Composition that is used to store several instances of the composited data type is referred to as containment. Examples of such containers are arrays, associative arrays, binary trees, and linked lists.

In UML, containment is depicted with a multiplicity of 1 or 0..n (depending on the issue of ownership), indicating that the data type is composed of an unknown number of instances of the composited data type.

Containership is different from inheritance. As inheritance is "is-a" relationship while containership is "has-a" relationship. In OOP supported languages, containership means an object is created within another object. It is sometimes referred as nesting as well. The class which contains objects/s of other class/es is called container class.

For Example in C++:

class A
{
        int a;
}x;

class B
{
        A y; // All the data members and member functions of class A can be accessed through the object 'y'
}z;

See also

External links





Licensed under CC BY-SA 3.0 | Source: https://handwiki.org/wiki/Containment_(computer_programming)
28 views | Status: cached on July 14 2024 17:49:32
↧ Download this article as ZWI file
Encyclosphere.org EncycloReader is supported by the EncyclosphereKSF