Professional Documents
Culture Documents
Presented By:-
AKSHAT GUPTA
BCA209
35225502019
An Introduction To Classes
A class is a building block of OOP. It is the
way to bind the data and its logically related
functions together.
An abstract data type that can be treated
like any other built in data type.
Class Definition
Class head class name_of_class.
Class body {
};
Class Syntax
class classname{
Access specifier :
Member variable Declaration;
Member Function Declaration;
};
#include<iostream>
Example using namespace std;
class maths{
int x,y;
public:
void input() //creating a member function to take
input from the user
{
cout<<"Enter two integers : \n";
cin>>x>>y;
}
void add() //creating a member function to perform
addition of the entered no.
{
cout<<"Result : "<<x+y;
}
};
Access Specifiers & Its Types
Access specifiers define how the members
(attributes & methods) of a class can be accessed.
In C++ there are three types of access specifiers:-
1.Public.
2.Private.
3.Protected.
Access Specifiers & Its Types(Contd.)
https://www.geeksforgeeks.org/c-classes-and-objects/
https://www.w3schools.com/cpp/cpp_classes.asp
https://www.slideshare.net/PayelGuria/class-and-objects
THANK YOU!