Classes in C++
A class is a user defined data type that
contains data members and member function.
Definition and declaration of class:
A class definition is a process of
naming a class and data variable and operations of class.
A class declaration is representation
of objects of the class and set of operations that can apply to objects.
The members of class are data members
and member functions.
The data variables of class are known
as data members.
The set of operations that are
performed on the objects of the class are known as member function.
Syntax:
class user_defined_nae
{
private:
data
member
member
function
public:
data
member
member
function
protected:
data
member
member
function
};
Ex:
class time
{
private:
int
hh,mm,ss;
public:
void
getdata();
void
putdata();
};
Here name of the class is time
Data members are hh,mm,ss
Member functions are getdata(),
putdata()
Comments
Post a Comment