Class

Classes in programming languages are user defined data types. But they behave like built-in data types. Classes are used in object oriented programming paradigm.

Class definition
Class is a collection of objects of similar type or Class is a construct which can be used as a template to create instances of itself known as class objects.

Example of a class in C++ :


class person
{
private:
string name;
int age;
public:
void getdata();
void display
{
cout<<"Name: "<<name<<endl;
cout<<"Age: "<<age<<endl;
}
};

Here name and age are data-members of the data-type string and integer respectively. Keywords private and public are the access specifiers and getdata and display are the member-functions. A function can be defined inside or outside a class.

The terms encapsulation and information hiding are closely related with class.