Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

Classes in C++

By: Rizwan Ullah


Class: BSSE (2nd)
Course: Object Oriented Programming
Class:
• A class is a collection of data and function.
• The data items and functions are defined with in the class.

• Defining a Class:
• A class is defined in a similar way as a structures is defined.
• The keyword ‘class’ is used to define the class.
Syntax:
• class class_name
•{
• body of the class
• };
Members of a class:
• A class contains data items and functions.
• The data items are called data members and the functions are called member
functions.
• Data Members:
• The data items of a class are called data members of the class.
• For Example:
• A class that has a four integer type and two float type data items is declared as:
• class bbb
•{
• int a, b, c;
• float a, b;
• };

You might also like