Documente Academic
Documente Profesional
Documente Cultură
Class
• A class is a user define data type which holds both data and function.
• The data included in the class i.e the internal data is called the
internal data or data member and the functions included is called the
member function.
• These member functions can manipulate the internal data of the class
Object
• Is an instant of a class.
• In terms of variables, class would be the type and an object would be
a variable.
Classes in C++
• A class definition begins with the keyword class.
• The body of the class is contained within a set of braces, { } ; (notice
the semi-colon).
class class_name
{ Any valid identifier
….
….
…. Class body (data member +
}; methods)
class classname
{
private:
variable declarations;
function declarations;
public:
variable declarations;
function declarations;
protected:
variable declarations;
function declarations;
} obj1, obj2,…..objN;
Class name
• Name given to a particular class (any user define name). It can also be
called as tag name of the class that act as the type specifier for class
using which we can create objects.
• The class is specified by keyword “class”
Data Members
• Data type properties that describe the characteristics of a class.
• We can declare any number of data members of any type in a class.
• E.g. int x;
Member functions
class class_name
{
private: private members or methods
…
…
…
public:
… Public members or methods
…
…
};
Class Example
• This class example shows how we can encapsulate (gather) a circle
information into one package (unit or class)