Class (computer programming)

In object-oriented programming, a class defines the structure, initial state and behavior of an object.

Object creation is called instantiation since it results in an instance of the class.

A member variable stores object state and a member function, a.k.a. method, defines object behavior. [1][2] The member variables specific to the object are called instance variables to contrast with class variables shared across the objects of the class.

In some programming languages, classes can only be defined at compile time. In other languages, classes are first-class citizens, generally objects, that can be created at runtime. A class that creates classes within itself is called a metaclass.

If the programming language supports inheritance, a class is extensible by allowing the definition of one class to be based on and extended from another.

  1. ^ Gamma et al. 1995, p. 14.
  2. ^ Bruce 2002, 2.1 Objects, classes, and object types, https://books.google.com/books?id=9NGWq3K1RwUC&pg=PA18.

From Wikipedia, the free encyclopedia · View on Wikipedia

Developed by Tubidy