Classes in C++

c++ classes

Classes in C++ : An object oriented programming approach is a collection of objects and each object consists of corresponding data structures and procedures. The program is reusable and more maintainable. The important aspect in object oriented programming is a class which has similar syntax that of structure.

It is a collection of data and member functions that manipulate data. The data components of class are called data members and functions that manipulate the data are called member functions. It can also called as blue print or prototype that defines the variables and functions common to all objects of certain kind. It is also known as user defined data type or ADT(abstract data type) A class is declared by the keyword class.

Syntax for declaring a classes in c++ is:

class class_name
Access specifier:

Example :

int length,breadth,height;
int calculate_area ()
int a = length * breadth;
return a;

double Calculate_Volume()
double b = length * breadth * height;
return b;

Here we have defined a class with name Rom. In this the variable declared are length breadth and height which are known as data member. And calculate_area and Calculate_Volume are the data function of a class.

2 thoughts on “Classes in C++”

  1. Pingback: Unconditional control statement in C++ -

  2. Pingback: Object's in C++ -

Leave a Comment

Your email address will not be published. Required fields are marked *